HomeSelenium

Selenium Locators – Types of CSS Selectors

Selenium Locators – Types of CSS Selectors

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

In the previous articles, I have explained ‘What is a CSS Selector?’ and the Hierarchy of HTML Source Code

In this article, I am going to explain the types of CSS Selectors.

Let’s get started.

Types of CSS Selectors

The following are the two types of CSS Selectors:

  1. Absolute CSS Selectors
  2. Relative CSS Selectors

Types of CSS Selectors

What is an Absolute CSS Selector?

Absolute CSS Selector has the Complete Path from the Root element and is used for locating the UI elements on the Web Pages.

Example: html > body > p[id=’para1′]

In the above example, the root element is html and the complete path starts from the root element html and goes down the till it reaches the required p tag

Note: The above example will be explained in detail in the upcoming articles, till then understand it at a high level.

What is a Relative CSS Selector?

Relative CSS Selector is nothing but the direct or shortcut path and is used for locating the UI elements on the Web Pages.

Example: p[id=’para1′]

In the above example, we have used a shortcut or direct path to locate the UI element on the web page.

Note: The above example will be explained in detail in the upcoming articles, till then understand it at a high level.

As you now understood the different types of CSS Selectors and their differences, I will explain the detailed way of constructing both types in a step by step manner 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>>

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 *