QaMantra: Locators in Selenium

Locators in Selenium


Locators provide a mechanism to access the HTML elements on a web page. Once we locate an element/object on any web page, Then to get or store the Webelement we use findElement() or Findelements()  method to find or strore the located webelement or List of elements then we can write test cases to execute on them.

Selenium uses what is called locators to find and match the elements of your page that it needs to interact with

                           For example, If we would like click on any button then locators will help me to click on button , We will see that in details in the subsequent sections of this tutorial.

Types of Locators in Selenium 

Selenium webdriver Have 8 locators to find the Web elements on web page , We have mentioned the list of locators as per priority to be used while Coding.

  • ID
  • Name 
  • Link Text
  • Partial Link Text
  • Tag Name 
  • Class Name
  • Css Selector
  • XPATH   - Absolute and Relative 


No comments: