Reputation: 136
I'm trying to access an HTML element using Selenium (Java) but am currently having trouble. The element is located within this structure:
<nav>
<ul class="...menu"> id="...menu">
<li id="Ignore..."> </li>
<li id="Test tab">
<a href="/.../..." title="Tab">Tab</a>
</li>
</ul>
</nav>
I need to access and click "Tab"
which appears as a button. What is the best method to access this button? I have tried .findElement(By.name("..."));
and similar without success. Once "Tab"
has been selected I then plan to call .click()
.
Thanks in advance.
Upvotes: 2
Views: 958
Reputation: 2002
Go with this solution
driver.findElement(By.xpath("//a[text()='Tab']")).click();
Upvotes: 1