O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding elements

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 findElementByID(). 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required