Locating Web Elements by id

0 votes

The most common attribute key names are class and id, where id has to be unique over the entire HTML page (according to the HTML specification). This locator strategy allows Selenium WebDriver to find that unique element and perform some action against it.

Example HTML:

<input id="username" type="text" />

We can use one of the following locators:

#username

If we want to be more explicit we can write:

input#username

Using the latter we explicitly mention the type of element.

 

Examine your knowledge and play the ‘locator game‘.

Please follow and like us:
Follow by Email
Facebook
Google+
http://www.seleniuminaction.com/locating-web-elements-by-id/
Twitter
LinkedIn
Locating Web Elements by name
Access in-browser Development Tools

Leave a Reply

Your email address will not be published. Required fields are marked *