How To Locate Element By ID Locator In Selenium

In the previous post we have seen “locators in Selenium”. In this post, we discuss “How To Locate Element By ID Locator”. Find the below links on How to find elements on a web page using different types of locators.

1. “How To Locate Element By Name Locator
2. “How To Locate Element By Class Name Locator
3. “How To Locate Element By Tag Name Locator
4. “How To Locate Element By Link Text/Partial Link Text Locator
5. “How To Locate Element By CSS Selector Locator
6. “How To Locate Element By XPath Locator

Coming to the actual post “How To Locate Element By ID Locator”.

ID Locator:

ID’s are unique for each element so it is common way to locate elements using ID Locator. As per W3C, ID’s are supposed to be unique on a page and it makes ID’s are the most reliable locator. ID locators are the fastest and safest locators out of all locators.

id = id of the element


  1. Open Mozilla Firefox and navigate to Gmail application.
  2. Open Firebug and inspect the enter your email input box. Take a note of its ID. Follow the below screenshot to do so.
  3. Copy the below mentioned script and execute in your system.

Locate Element By ID Locator

Value to be added in the method:


How to locate element by id locator

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap