Working with elements and their attributes
In the Using element attributes in XPath queries section, we saw how useful it is to find an element by looking at its attributes. An element may have the same name but a different value, so finding its according to its attributes can be extremely powerful.
Finding elements by their attributes
In this example, we will look for the button that has the value chocolate
. On web page buttons, a value is what is displayed on the screen.
The syntax for looking at the attribute is node[attribute='value']
. So in the case of the button with the value chocolate
, it will be input[value='chocolate']
. If you were to put that into Selenium IDE, it will have the format css=input[value='chocolate']
and when you click the ...
Get Learning Selenium Testing Tools - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.