WebDriver unable to locate element (link/Java)

I'm using Selenium to navigate a webpage which has a link called "Mail", using WebDriver (just recently switched from RC to WebDriver). I want to click on the link but the testcase always fails with the error:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Mail"}

When inspecting the element with Firebug I get the following HTML:

<a href="url/New-Doc" target="_top" fahidden="false" faswid="e-switcher-mail" faprop="p-e-switcher-function-id">Mail</a>

This is the Java which attempts to click the link:

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

I can see that the element is present on screen but still, the test case fails.

Does anyone know what I might be missing here or an alternative way to find the link element?


Try via XPath. Example:


Would also be worthwhile double checking to ensure there are no iframes on the page.

Even i had faced this situation once. View your source code and find out if the element you are looking for is inside a frame. If yes, first switch to the frame in which the element is located and then look out for the element. It worked this way for me.

Need Your Help

Issue with creating class file

java class text methods java-7

I am creating a program to read and output baseball statistics. I am trying to create a class file that reads the txt file which consists of the team name followed by 20 batting averages.

Expandable ListView with JSON Data in android

android json dynamic-data expandablelistview

I have a big problem and I have been searching on the web to have a good solution for this problem but I couldn't find any approach for this problem so I want help.