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 XPath Axis

In the first example, we are going to find a button and then find its sibling. In this example, the query that we will generate is equivalent to xpath=//div[@class='leftdiv']/input[2].

  1. We will start by finding the first element for our query which is //input[@value='Button with ID']. Place that into Selenium IDE Target textbox and see which element it highlights.
  2. There is another button below the one that is highlighted and that is the element that we need to work with in this section. The button is the next input item in the HTML, so it is elements following-sibling that we need. Our locator will look like //input[@value='Button with ID']/following-sibling::input[@value='Sibling Button'] and if it was placed ...

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