So let’s say my structure looks like this at some point:
..........
<td>
[...]
<input value="abcabc">
[...]
</td>
[...]
<td></td>
[...]
<td>
<input id="booboobooboo01">
<div></div> <=======I want to click this!
</td>
.........
I need to click that div, but I need to be sure it’s on the same line as the td containing the input with value="abcabc". I also know that the div I need to click (which doesn’t have id or any other relevant attribute I can use) is in a td at the same level as the first td, right after the input with id CONTAINING “boo” (dynamically generated, I only know the root part of the id). td’s contain nothing relevant I can use.
This is what I tried as far as xpath goes:
//input[@value='abcabc']/../td/input[contains(@id,'boo')]/following-sibling::div
//input[@value='abcabc']/..//td/input[contains(@id,'boo')]/following-sibling::div
None of them worked, of course (element cannot be found).
I want to know if there’s a way of selecting that div and how.
EDIT: //input[@value='abcabc']/../../td/input[contains(@id,'boo')]/following-sibling::div is the correct way. This was suggested by the person with the accepted answer. Also note that he offered a slightly different way of doing it. See his answer for details.
Try
Note that
//input[@value='abcabc']/..only goes up to the parent<td>, that’s why your’s did not work.