Chakra
Chakra

Reputation: 2557

How to get the HTML TD sibling following (the TD whose child table has a TD whose span i got)?

I have a td (id=opdBrowser:todaysPatientsTable:5:j_id556) which has a table(class=panelGrid) which has the condition i want. Now i need to get out of the table and go to the anchor id="opdBrowser:todaysPatientsTable:5:createQueueNoLinkId" which is in the peer td id="opdBrowser:todaysPatientsTable:5:j_id675".

what is the XPath when i am in the span of the td of the table, and need to go out of the table and get the next td ?

The relevant HTML is here :

<td id="opdBrowser:todaysPatientsTable:5:j_id556" class="rich-table-cell alignAndWrap ">
<table class="panelGrid" width="100%" cellspacing="2" cellpadding="2" border="0">
</td>
<td id="opdBrowser:todaysPatientsTable:5:j_id675" class="rich-table-cell alignAndWrap ">
<a id="opdBrowser:todaysPatientsTable:5:createQueueNoLinkId" title="Create Encounter">

Upvotes: 0

Views: 65

Answers (1)

Robin
Robin

Reputation: 9644

If you need to go up a level, you can use .., for example:

//table[@class="panelGrid"]/../../td[a/@title="Create Encounter"]

would select the td containing a link titled "Create Encounter", in the same table as your first selected table.

If you really want the following sibling, and not select the sibling you want with some condition, you can also do

//td[table/@class="panelGrid"]/following-sibling::td

Does it answer your question?

Upvotes: 1

Related Questions