Tutorial by Examples

The Protractor API allows CSS element locators to use the jQuery-like shortcut notation $(). Normal CSS Element Locator: element(by.css('h1.documentation-text[ng-bind="title"]')); element(by.css('[ng-click="submit"])); Shortcut $() CSS Element Locator: $('h1.documentatio...
A locator in Protractor is used to perform action on HTML dom elements. The most common and best locators used in Protractor are css, id, model and binding. For example commonly used locators are: by.css('css-selector') by.id('id')
To select an element by an exact HTML attribute use the css locator pattern [attribute=value] //selects the first element with href value '/contact' element(by.css('[href="/contact"]')); //selects the first element with tag option and value 'foo' element(by.css('option[value="f...
To select an element by an HTML attribute that contains a specified value use the css locator pattern [attribute*=value] //selects the first element with href value that contains'cont' element(by.css('[href*="cont"]')); //selects the first element with tag h1 and class attribute that...

Page 1 of 1