I use Java and Selenium and testng for Windows 7. My HTML looks like this (it's just part):
<TR>
<TH>
<SPAN>Some Text 1</SPAN>
</TH>
<TH>
<SPAN>
<A id="someid" href="http://someurl">
<SPAN> Some Text 2</SPAN>
</A>
</SPAN>
</TH>
</TR>
In other words, "Some Text 1" and "Some Text 2" are at different levels. I am trying to find XPath to find them. I can't use *//TR//SPAN*it because it will get extra SPANover "Some Text 2". I cannot search SPANwith text, because some of them that I find will not have any text. I believe that I can assume that what SPANI'm looking for will always be the lowest level SPANunder TH.
So, can I use XPath? I suppose, instead of using @FindBy, I could do some kind of dynamic recursive loop to find the gap and continue to search for spans under it until I come to the sheet, but that sounds pretty complicated.
source
share