Leveraging the XPath axis with elements

As we have seen, XPath is normally only used if the element we need to interact with is not accessible by normal means. In this section of the chapter, we will have a look at leveraging the XPath axis in our queries to find the element that we wish to interact with. An example that I have used in the real world was to find a table cell that had specific text, then traverse the tree backwards to find the edit button so that I can click on it. This may seem laborious just to click on an edit button, but it is extremely common according to the Selenium users forum on Google Groups.

Using the XPath axis

In the first example, we found a button and then its sibling. In this example, the query that we will generate ...

Get Learning Selenium Testing Tools - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.