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 -

  1. get element using buttontext.

    element(by.buttontext('reset')); 
  2. you can add custom locator button using addlocator in protractor. here's example of it.

  3. use csscontainingtext element using both css , text properties.

    element(by.csscontainingtext('.btn', 'reset')); 
  4. if @ have longer text in button element(for ex, "reset value"), use partialbuttontext it.

    element(by.partialbuttontext('value')); 
  5. 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 -

  1. use classname element -

    element(by.classname('btn')); 
  2. use tagname element if button element on page, rare case -

    element(by.tagname('button')); 

hope helps.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -