views:

55

answers:

1

Suppose I have a simple table, like this:

Smith    |  Select
Jones    |  Select
Johnson  |  Select

And I need to write a Selenium test to select the link corresponding to Jones. I can make it click the "Select" in the 2nd row, but I would rather have it find where "Jones" is and click the corresponding "Select". I'm thinking I may need to incorporate JQuery to accomplish this?

+1  A: 

Use an xpath expression like "//tc[.//text() = 'Jones']/../tc[2]/a" which looks for a table cell whose text contents are 'Jones' and then naviagates up to that cells parent, selects the second table cell of that parent, and then a link inside the second table cell.

Wesley Wiser