Javatpoint Logo
Javatpoint Logo

Locating Strategies- (By CSS-Tag, Class and Attribute)

In this section, you will learn how to locate a particular web element using CSS - Tag, Class and Attribute Selector.

Under this scenario, we will inspect the search text box of one of the most popular search engine i.e. Google.

As we know that locating a particular web element involves inspection of its HTML codes. Therefore, follow the steps given below to locate the textbox provided on the initial web page of Google Search Engine.

Locating Strategies- By CSS-Tag, Class and Attribute
  • It will launch a window containing all the specific codes involved in the development of the textbox.
Locating Strategies- By CSS-Tag, Class and Attribute
  • Take a note of its Tag, Class and Attribute.
Locating Strategies- By CSS-Tag, Class and Attribute

The Java Syntax for locating a web element through CSS - Tag, Class and Attribute Selector is written as:

Therefore, for locating the Textbox on the Google Search Engine page we will use the input tag, Class and Name attribute:

Similarly, for locating the Google Search button on the Google Search Engine page we will use its respective input tag, Class and Name attribute:

We have created a sample script for you to get a better understanding of how to use CSS - Tag, Class and Attribute Selector. We have embedded comments in each section of code which will guide you through whole automation process.






Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA