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

Time for action – using findElementsById()

We are going to find an element on the page by using the findElementsById() method that is on each of the Browser Driver classes. findElement calls will return a WebElement object that we can do actions on.

Follow these steps to see how it works:

  1. Open your Java IDE. Intellij or Eclipse are the most used.
  2. We are going to use the command:
    List<WebElement> elements = ((FindsById)driver).findElementsById("verifybutton");
    Assert.equals(1, elements.size());
  3. Run the test from the IDE. It will look like the following screenshot:
    Time for action – using findElementsById()

What just happened?

We have just seen how we can find an element by using the findElementsById ...

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