I try to get a href from an anchor according to linkText given with func param (for example here Westwood or Linda).
In the code below I changed classes values (cause of company info), but beside thats the code. For each <tr>
the hrefs are identical for both <td>
, but different from <tr>
to <tr>
I get the 1st href with:
driver.findElemnt(By.xpath("//a[@class = 'class Name of a']").getAttribute("href")
or the same with:
xpath="//a[@class = 'class Name of a'][1]";
but when I go:
"//a[@class = 'class Name of a'][2]" or 3 or 4...
or when I use:
By.partialLinkText
It fails, so I never get beyond the 1st <td>
of the first <tr>
.
The Error: oopenqa.selenium.StaleElementReferenceException : Element is no longer attached to the Dom.
The Elements are visible all the time, so its not a visibility problem.
This is the html:
<tr class="Class name for tr here">
<td headers="description _ CustomerList:lastName">
<a href="some path index=0" class="class Name of a">Westwood</a>
</td>
<td headers="description _CustomerList:firstName">
<a href="some path index=0" class="class Name of a">Linda</a>
</td>
</tr>