Finding elements - Selenium

When working with WebDriver on a web application, we will need to find elements on the page. This is the core to being able to work. All the methods for doing actions to the web application like typing and clicking require that we find the element first.

Finding an element on the page by its ID

The first item that we are going to look at is finding an element by ID. Finding elements by ID will be one of the easiest ways to find an element. We are going to start with findElementBylD(). This method is a helper method that sets an argument for a more generic findElement call. We will see now how we can use it in action. The method's signature looks like:

findElementById(String using);

The using variable takes the ID of the element that you wish to look for. It will return a WebElement object that we can then work with.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics