HomeSelenium

Locators for Selenium – Demonstrating Class Name Locator

Locators for Selenium – Demonstrating Class Name Locator

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

In the previous articles, I have explained what are locators? and Different types of locators.

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:

Locators for Selenium - Navigate to Omayo in Chrome

3) Scroll down and right click on the ‘Locate using Class’ Text Box field and select ‘Inspect’ option as shown below:

Locate Using Class - Inspect

4) Observe that the HTML code related to the ‘Locate using Class’ Text box field got highlighted as shown below:

Locate Using Class - HTML Highlight

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.

Locate Using Class - Class Name Locator

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.

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>>

If you like this article, share it on LinkedIn using the below button:

Comments (0)

Leave a Reply

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