I have a web application where there are two links with same name.
When i use
driver.findElement(By.linkText("Travel and Expense Center")).click();
i get error stating there is no webelement.
i tried using xpath
driver.findElement(By.xpath("//A[@class='PTNAVLINK' and @name='EP_SC_SP_EMPLOYEE_TE_CENTER']")).click();
for this also i am getting the same error.
the difference between the two links with same are their class property...
can you please advice ?
best way for someone to trouble shoot is to attach the page's html source. It's hard to say without context.
SDET / Consultant
Do they both navigate to same page on click!!!!
Use Xpath to find the first link with given name and clicl
Winds of Change
Do they have the same class name???
Hey try this.
<font class="small">Code:</font><hr /><pre>
driver.findElement(By.Xpath("//a[text()='ContainsTravel and Expense Center' and position()=1")).click();
Thank/Like to help others if my input helped you !!!
I am speaking for myself, not for my employer nor any one.