In this article, I am going to practically demonstrate the usage of Class Name locators for locating the UI elements on the Web Pages.
Let’s get started.
Locators for Selenium – Demonstrating Class Name Locator
Follow the below steps for locating the UI elements on the Web Pages using Class Name Locator:
1) Install Selenium IDE, if not installed in your chrome browser (Refer steps to install Selenium IDE in your chrome browser)
2) Navigate to http://omayo.blogspot.com/ in your chrome browser as shown below:
3) Scroll down and right click on the ‘Locate using Class’ Text Box field and select ‘Inspect’ option as shown below:
4) Observe that the HTML code related to the ‘Locate using Class’ Text box field got highlighted as shown below:
5) Observe that the above-highlighted HTML code has a class attribute with a value. We can use this class attribute value (i.e. classone) as a class name locator for locating the ‘Locate using class’ text box field on the Web Page.
6) Demonstration of Class Name locator is not possible in Selenium IDE. Hence I am postponing its demonstration to our Selenium WebDriver articles. Till then we can understand that the ‘classone’ value of class attribute name in the above screenshot forms the Class Name Locator and we can locate the UI elements the Web Pages like ‘Locate using class’ text box field etc. in Selenium WebDriver.
Hence in this example, we have used the Class Name locator (i.e. name=q) for locating the ‘Locate using class’ text box field on the Web Page having the class name attribute value as ‘classone’.
In the next article, I will demonstrate the next locator i.e. Link Text locator for locating the UI elements on the Web Page.
- > 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 🙂
On a mission to contribute to the Software Testing Community in all possible ways.