Locating strategy

In Previous section, we have cleared on how to use the driver to communicate with real browsers. In this section, we will discuss on the Locating strategy for the Selenium WebDriver.

Now you can ask question that how we will handle element of the website like home, image, content etc.

“Location Strategy” is the appropriate answer for this. From the name you can guess that this is a strategy to locate the element of the web page.

Do you know what are the elements of the web page?

Yes. You are correct. Elements of the web page are the wrappers and display templates. Following are some example of Elements of web page.

  • Components
  • Wrappers
  • Display Templates
  • Page Body
  • CSS
  • XSLT etc.

Now a days, Selenium is widely used as web automation tool which has lots of advantages like it is Open Source with many more advanced features to handle the web element So it provides a awesome user experience while execute.

Locating elements is the heart of the selenium automation tool. You can locate an element of the web page by a several method like

Locating Strategy

From the above diagram you can notice that there are several ways to locate the web element in selenium web driver. For example, if you want to find the element by ID then you need to use the method findElement(By,id(“ID oif the element”)).

In the same we you can use findElement(By.name(“Name attribute of the web element”)). and for tag name you need to use findElement(By.tagName(“Tag Name of the Web Element”)).

So we have understood that by using findElement(), we can locate the web element by using multiple ways like ID, class etc.

Let’s understand the Locators in detail one by one.

Leave a Reply

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