I am using Selenium WebDriver wrapped in PHPUnit and Sausage to test clicking a button in a specific row in a table that's laid out similar to:
<tr id="dynamically generated 1">
<td class="foo">
<div class="bar"></div>
</td>
<td class = "mybutton">
<span class = "icon clickable"></span>
</td>
</tr>
<tr id="dynamically generated 2">
<td class="foo">
<div class="baz"></div>
</td>
<td class = "mybutton">
<span class = "icon clickable"></span>
</td>
</tr>
In particular, I want to click a specific element #mybutton > span.icon.clickable
whose sibling is .foo
with child .baz
. The "whose sibling is .foo
with child .baz
" requirement is the only way I can currently identify the correct element, as other rows in the same table have element #mybutton > span.icon.clickable
, and the ids for those rows are dynamically generated.
At the moment I am using XPath, but as you might expect, performance on FF
and IE
is horrendous. Is there a method for retrieving the value of tr#id
from the element tr#id div.bar
? If I can get this, I can use the id to use CSS to find the element I am looking for. I am using PHP, but a solution in any language would be useful.
Alternatively, a more straightforward CSS3 solution would work, but after quite a bit of reading, I've all but concluded that using a standard CSS3 selector is not an option for this case. Just in case there is something I'm missing, is there a CSS3 solution for this? I know there is a CSS4 solution, but I need full browser support, so until all the browsers I am testing support CSS4, I'll have to rely on CSS3.
Thanks in advance.
EDIT: Until there is better cross-browser support for CSS4, I need to use CSS3