javascript - how to Find element Locator in Protractor -
iam new protractor, please me find element locator using below code in protractor/angularjs have tried using xpath , css. locator can used code
<button type="submit" value="autofocus" class="btn" data-ng-click="reset()">reset</button>
here various methods can use apart xpath , css. locators specific protractor -
get element using
buttontext
.element(by.buttontext('reset'));
you can add custom locator button using
addlocator
in protractor. here's example of it.use
csscontainingtext
element using both css , text properties.element(by.csscontainingtext('.btn', 'reset'));
if @ have longer text in button element(for ex, "reset value"), use
partialbuttontext
it.element(by.partialbuttontext('value'));
you can use shortcut find elements using css.
$('.btn'); // = element(by.css('.btn'))
more details of locators in protractor here.
you can use various general locators -
use
classname
element -element(by.classname('btn'));
use tagname element if button element on page, rare case -
element(by.tagname('button'));
hope helps.
Comments
Post a Comment