In Selenium Automation, Locators are used to locate the UI (User Interface) elements of a page like Text Box field, Button etc
First lets understand what are the UI elements using the following example:
Example#1 - Suppose we've to automate a test, where the User have to log in to Facebook
Steps to Log In to Facebook application:
- Browse www.facebook.com in any browser
- In 'Facebook' Log In page, enter your email id into the Username text box.
- Enter your Facebook password into the Password text box.
- Click on 'Log In' button.
In the above example, Username text box, Password text box and Log In text box are the UI elements to be identified by the automation tool.
Example#2 - Suppose we've to automate a test, where the User have to search for 'selenium-by-arun' in Google.
Steps to search for 'selenium-by-arun' in Google:
- Browser www.Google.com in any browser
- In 'Google' page, enter text 'Selenium-by-arun' into the 'Search' text box
- Click on 'Google Search' Button
In the above example 'Search' text box and 'Google Search' button are the UI elements to be identified by the automation tool.
So now you have understood how to identify the UI elements required by our automation tools manually on any page. But how can Selenium Automation Tool identify the UI elements for automating the tests. So the simple answer is by using the Locators. Lets find out what actually the locators are:
Identifying an UI element on the application screen is an important feature for any automation tool. Locators allows the Selenium Automation tool to find UI elements on a page that can be used in our automation tests.
i.e. The Selenium Tool uses Locators to find and match the elements on your page that it needs to interact with while running the automation scripts.
Now lets go forward to find out the different types of Locators that help the Selenium Tool in identifying the UI elements on any page (Explained in the next post) .
Please comment below to feedback or ask questions.
Using Different Types of Locators will be explained in the next post.
i.e. The Selenium Tool uses Locators to find and match the elements on your page that it needs to interact with while running the automation scripts.
Now lets go forward to find out the different types of Locators that help the Selenium Tool in identifying the UI elements on any page (Explained in the next post) .
Please comment below to feedback or ask questions.
Using Different Types of Locators will be explained in the next post.
4 comments:
Hi,
Could you please explain what is the difference between UI element and object?or are they both same?
Thanks,
Divya
In Automation perspective, we can call UI elements as Objects.
Example -
1. Locate the UI element 'Login' button
2. Locate the object 'Login' button
Hi Arun,
Could you please provide return type of all the methods used in Selenium, It would be great help.
Thanks,
Ankit
Hi, when i saved the script with html extension and double click, the wep page does not open, but it shows the table view of the script i saved in the html file. A line in reply to me will be helpful. I am a beginner
Post a Comment