☰ See All Chapters |
How to locate element by ID locator in selenium
According to World Wide Web Consortium (W3C) ID’s are unique for each element so it is easy way to locate elements using ID Locator. ID locators are the fastest out of all locators. Many say that ID locators are safest locators, this is not true, because developer may use duplicate ID’s and as browsers do allow bypassing W3C rule. While populating list and tables developers sometimes use same ID’s for all the items in list. Below is the syntax and example for id locator:
Syntax: | id=value of id attribute |
Example: | id=firstname |
Note: There should be no space/emptyspce before and after = (equals)
Let us test id locator from our test page Test Page
All Chapters