Selena
Selena

Reputation: 2268

Selenium: Element not located via LINK_TEXT or PARTIAL_LINK_TEXT

I am attempting to find a robust way to locate the logout link in a dropdown user menu in a web app. This is the html for for the link:

<a href="logout.jsp">Logout</a> 

I have attempted the following:

    /** The logout link */
@FindBy(how = How.PARTIAL_LINK_TEXT, using = "Logout")
private WebElement logoutLink;

and

    /** The logout link */
@FindBy(how = How.LINK_TEXT, using = "Logout")
private WebElement logoutLink;

However, I keep getting a NoSuchElementException when attempting the access the logout link. The LINK_TEXT method worked previously and mysteriously stopped working in the last few days. I tried the PARTIAL_LINK_TEXT method just for kicks and it fails as well. Is there any reason anyone can give me why this is failing to locate the link. I use PageFactory.initElements on the class that includes this link and other web elements are located without a problem.

Upvotes: 1

Views: 5488

Answers (2)

Selena
Selena

Reputation: 2268

It's a defect in Selenium. I've entered a bug and will be posting a sample page and script to reproduce it sometime next week.

http://code.google.com/p/selenium/issues/detail?id=5772

Upvotes: 3

user1769790
user1769790

Reputation: 1343

Please check the actual text for the link once again. It's not working may be there can be spaces or may be upper case , lower case in the text. You can also try,

@FindBy(linkText = “Logout”)

Partial Link Text

@FindBy(partialLinkText = “Logout”)

Upvotes: 2

Related Questions