I have been using the find() method is order to find relative xpaths, but it is not working like I thought it would, and I am wondering if i am misunderstanding how it is meant to work
On the page I am testing I have 2 thead
elements. one is for small screens while the other is for large screens.
Assume each thead
has child <tr>
and 4 <th>
grandchildren
assume I have Navigator element myElement
which is pointing to only 1 of the theads and not the other (single element here) if I want all of the <th>
s under myElement
specifically, I figured I could say:
myElement.find(By.xpath("//th"))
What I get as a return appears to be both sets of <th
>s from both thead
s even though I expect to see only the set relative to myElement
.
Am I misunderstanding .find()'s use case, or do I have another issue?
(no need to try and figure out what that issue is. I simply want to assert i am using .find() correctly.)
switching //th
to .//th
did the trick for me. Credit goes to melpomene though