user3545665
user3545665

Reputation: 1

Locating Hyperlink with selenium webdriver with Java

I have the below href link with the + sign. I don't have the Id or name for this. Is there any i can locate and click this [+] link. Can anybody please share the code.

<td class="expandCollapseLink"><a href="" onclick="toggleIds(889358, this); return false;">[+]  </a></td>

Upvotes: 0

Views: 96

Answers (2)

DMart
DMart

Reputation: 2461

//td[@class='expandCollapseLink']/a should be all the xpath selector you need. //td[@class='expandCollapseLink']/a[contains(@onclick,"toggleIds")] should also work and be a bit more specific.

Upvotes: 0

E02190
E02190

Reputation: 11

You can use an element's inner text to locate the element. Try using the following XPATH to locate the link: //td[@class='expandCollapseLink']/a[contains(text(),'[+]')]

You may find this to be a useful cross-reference for different XPATH/CSS selectors in the future. I use it very frequently: https://www.simple-talk.com/dotnet/.net-framework/xpath,-css,-dom-and-selenium-the-rosetta-stone/

Upvotes: 1

Related Questions