I’m using selenium’s webdriver.find_element_by_link_text('searchterm') to get a webElement. I can then find the href value by using webElement.get_attribute('href') With the ‘href’ I’m able to locate the element itself by xpath:
.//*[@href=webElement.get_attribute('href')]
The problem is that this isn’t the link I want to click, the link I want to click has the text ‘google reader’ and is three colums further down the line:
<tr id="AB2Xq4gXoer9sCEEr-rRcZjVz1p021-gdypaX-U" class="ACTIVE">
<td class="checkbox">
<td class="alert-type" colspan="2">
<a href="RETRIEVABLE ATTRIBUTE">FOUND TEXT</a>
</td>
<td class="alert-volume">Only the best results</td>
<td class="alert-frequency">As-it-happens</td>
<td class="alert-delivery">
<a href="THE ELEMENT I WANT TO CLICK">Google Reader</a>
<a href="another link">
</td>
The problem here is that there are a series of “google reader” links, so this term cannot be used
Any chance of navigating down to the element/ link I want via path?
I’ve been trying by going to parent, and then down to the right child, but I’m just not getting there.
Appreciative of any time and help given!!
Sincerely
Compare the
a‘stext()to the string:To get from the FOUND TEXT to the corresponding
Google Reader, use..(parent) andfollowing-sibling: