On my web-page i have a username dropdown list when we take the mouse over it we get the logout option and then only user is able to logout. While automating, as the logout link is hidden, webdriver is not able to interact with it. Please suggest some solutions.
Asked
Active
Viewed 2,869 times
-1

user1728406
- 257
- 3
- 6
1 Answers
1
Use Actions
class to mousehover and then, when the logout link is visible click on it. You can use the below code for reference.
Actions actions = new Actions(driver);
//for hovering over the username field
WebElement menuHoverLink = driver.findElement(By.linkText("username"));
actions.moveToElement(menuHoverLink).perform();
//for clicking the logout link
WebElement logoutLink = driver.findElement(By.linkText("logout"));
logoutLink.click();

HemChe
- 2,249
- 1
- 21
- 33
-
Hi HemChe thanks for the reply...I tried the above code but still im getting an error that " Unable to locate element: {"method":"link text","selector":"Sign Out"} " . – user1728406 Apr 26 '13 at 04:28
-
Hi Hemche, The above code is working fine for moving the element to username link,however it is not able to click on the Sign out link. It is still giving tha same error. – user1728406 Apr 26 '13 at 04:41