Reputation: 707
Okay, given the following situation:
<tr>
<td> input="the wrong radio button" </td>
<td> the wrong title </td>
</tr>
<tr>
<td> input="the right radio button" </td>
<td> the right title </td>
</tr>
I have "the right title" already stored in a variable. How can I make Selenium click the right radio button?
The radios have dynamic id´s (e.g. foo_bar_4711) that aren ´t directly related with the title.
I would need something like "click the radio button in the tr that containts a td having the text you are looking for".
Upvotes: 1
Views: 2499
Reputation: 32437
Use xpath, something like //td[contains(text(),'the right title')]/../td[1]
. The key is to use ..
to go back up one level in the tree.
Upvotes: 3
Reputation: 9569
You need an XPath locator that differentiates between the two buttons. Something like xpath=tr[td[.='the right title']]//input
. In English, that means "the input button contained within the table row that contains a table cell who's text is 'the right title'".
Upvotes: 1