HomeSelenium

Locators for Selenium – What are Locators?

Locators for Selenium – What are Locators?

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

Before I start explaining about Locators, we have to first understand the UI Elements?

What are UI Elements?

UI Elements can be anything that is displayed on the Applications. The following are the different examples for UI Elements:

  1. Buttons
  2. Checkboxes
  3. Radio Buttons
  4. Paragraph Text
  5. Menu
  6. Menu Option
  7. Dropdown field
  8. Multi-selection Box field
  9. Dropdown field option
  10. Text Box Field
  11. Text Box Field Label
  12. Text Area Field
  13. Images
  14. Hyperlinks
  15. Page Headings
  16. And so on

Let me practically show you different UI elements on the Web Application Page:

Locators - UI Elements

As we are now clear with UI Elements, now let’s understand Locators.

What are Locators?

Selenium is by default blind, as it doesn’t have any inbuilt capability or mechanism to locate any UI elements on the Web Pages.

In order to find UI elements on the Web Page, Selenium has to take the help of Locators.

Let’s take an example:

Example:  Automate Searching ‘iPhone’ at http://tutorialsninja.com/demo application and add it to cart from the displayed search results.

Steps:

  1. Navigate to http://tutorialsninja.com/demo
  2. Type ‘iPhone’ text into the Search Box field
  3. Click on Search Button
  4. In the displayed iPhone Search result, click on the ‘Add To Cart’ option

If we have to automate the scenario mentioned in the above example, Selenium cannot find or locate any of the UI elements required to automate i.e. Search Box field, Search Button, ‘Add To Cart’ option to perform click or type operations.

Selenium will take help of Locators in finding these UI elements which are required for automating the above example scenario. Using Locators, we will be creating locator for each and every UI element required and pass it to the Selenium Test Automation code.

Hence Selenium takes help of these locators for finding the UI elements on the web pages.

Hoping that you understood the role of locators in Selenium Automation, I will explain more about locators, their types, their priorities, practical examples, etc. in the upcoming articles.

Next Steps:

  • > To learn more about Selenium, continue to the next post (Click on Next Post link below)
  • > Check complete Selenium Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Arun Motoori

On a mission to contribute to the Software Testing Community in all possible ways.

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

Comments (1)

Leave a Reply

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

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp