protractor CSS Selectors Select element by an exact HTML attribute value

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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="foo"]')); 

//selects all input elements nested under the form tag with name attribute 'email'
element.all(by.css('form input[name="email"]'));



Got any protractor Question?