0
<tbody>
<tr class="odd">
<td>
<input id="nodeAccountOid" type="radio" onclick="setNodeAccountIdToCredentialCheck('E9E2930C4493B569E040A8C0158E4ABD');" style="width:100%;border:0px">
</td>
<td>E9E2930C4493B569E040A8C0158E4ABD</td>
<td>monacho1</td>
<td>urn:dece:org:org:dece:dece:cs</td>
</tr>
<tr class="even">
<td>
<input id="nodeAccountOid" type="radio" onclick="setNodeAccountIdToCredentialCheck('E9E2930C4494B569E040A8C0158E4ABD');" style="width:100%;border:0px">
</td>
<td>E9E2930C4494B569E040A8C0158E4ABD</td>
<td>monacho1</td>
<td>urn:dece:org:org:dece:coord:cs</td>
</tr>
<tr class="odd">
<td>
<input id="nodeAccountOid" type="radio" onclick="setNodeAccountIdToCredentialCheck('E9E2930C4495B569E040A8C0158E4ABD');" style="width:100%;border:0px">
</td>
<td>E9E2930C4495B569E040A8C0158E4ABD</td>
<td>monacho1</td>
<td>urn:dece:org:org:dece:300</td>
</tr>
<tr class="even">
<td>
<input id="nodeAccountOid" type="radio" onclick="setNodeAccountIdToCredentialCheck('E9E2930C4495B569E040A8C0158E4ABD');" style="width:100%;border:0px">
</td>
<td>E9E2930C4495B569E040A8C0158E4ABD</td>
<td>monacho1</td>
<td>urn:dece:org:org:dece:10</td>
</tr>
</tbody>
</table>

i want to select the radio button corresponding to urn:dece:org:org:dece:10 which is fourth row in the html provided. the row may change sometimes based on some inputs in AUT. please provide me the way to select it.

thanks in advance

2
  • Well what changes? Is it always urn:dece:org:org:dece:10? Commented Oct 29, 2013 at 14:32
  • @Arran : the urn:dece:org:org:dece:10 never changes but its position may chage.i want to select it accordingly Commented Oct 30, 2013 at 11:40

2 Answers 2

1

Since the text never changes, you can use that as a starting point within the DOM, and use XPath to navigate through to the input you need:

//td[.='urn:dece:org:org:dece:10']/parent::tr/descendant::input[@id='nodeAccountOid' and @type='radio']
  1. Get the td that has it's text equal to urn:dece:org:org:dece:10

  2. Get that td's parent tr

  3. From that parent tr, get the input that has an id equal to nodeAccountOid and has a type of radio.

Therefore it doesn't matter where exactly the elements are, as long as the XPath locator can navigate up to the parent and back down again to the input you need.

Sign up to request clarification or add additional context in comments.

1 Comment

the xpath you sent worked like a charm. thanks a lot and thanks for explaining the Steps too : )
0

The problem you are facing is to locate a certain element in the web page that may occur in different positions. If there is another element which can be identified easily by its content, id or name and there is a static relation between this element and the one you would like to locate, then you could use xpath. There are also some examples for this in the selenium documentation as far as I know.

1 Comment

i want to traverse along urn:dece:org:org:dece:10 row and Select the radio button irrespective of its position in page. can you please provide me a xpath to select that radio button. i have used the below xpath to select radio button which is at 4th row driver.findElement(By.xpath("(//input[@id='nodeAccountOid'])[5]")).click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.