This module adds a custom locators to a protractor instance that finds elements by their attribute using addLocator method.
- locator that finds element by
data-test-id
attribute- locator name -
dataTestId
- locator name -
- locator that finds element by
data-reactid
attribute- locator name -
dataReactId
- locator name -
$ npm install protractor-custom-locators
that you should put in your protractor.config.js:
import AddCustomLocators from "protractor-custom-locators/index";
onPrepare() {
AddCustomLocators.addDataTestId(protractor);
AddCustomLocators.addDataReactId(protractor);
}
The locator can then be used with element(by.locatorName(args))
.