1

I am using a Firefox WebDriver to test a web application. The web application has a top navigation bar, and some of the elements drop down into a menu when you hover over it.

I would like to click a button in the drop-down menu after hover. I am executing the following code:

    WebElement dropDown = driver.findElement(By
            .xpath("html/body/header/div/ul/li[6]/span[2]/a"));
    WebElement logoutButton = driver.findElement(By
            .xpath("html/body/header/div/ul/li[6]/ul/li[2]/a"));

    //build and perform the mouseOver with Advanced User Interactions API
    Actions builder = new Actions(driver);    
    builder.moveToElement(dropDown).perform();

    Thread.sleep(1000);

    logoutButton.click();

But I receive the following error:

Element is not currently visible and so may not be interacted with

Do you know how I can make this drop-down button visible? Is there any hack that I can do to make this work?

------ More Details ------

However, during the sleep, the browser shows the URL information in the bottom left corner of the screen, indicating that the web driver is actually hovering, but the button is not being made visible.

iosNoob
  • 153
  • 1
  • 9
  • you're obviously trying to click an element which isnt able to be clicked. Have you tried running it on a graphical machine and seeing what the browser does? Does your builder.moveToElement(dropDown).perform() actually drop down the elements? – Greg Aug 03 '12 at 02:48
  • http://stackoverflow.com/questions/6430462/how-to-select-get-drop-down-option-in-selenium-2 – Greg Aug 03 '12 at 08:09
  • Thanks for the help, Greg. You've honed in on the real issue: the perform() does not drop down the items. The link you've shared does not display the drop down items either. – iosNoob Aug 03 '12 at 17:50
  • ok a few questions: a. Have you tried using a dropDown.click() ? b. have you tried using different locators for your drop down? I mean using a full xpath is not the most recommended way to go about using your locators c. Have you tried looking deeper into the selenium javadocs for answers or possible solutions? If moveToElement isn't working, why not try a set of coordinates? Yes its hacky but it might work. d. Whats your html? that is always helpful for any reviewer looking at your post – Greg Aug 04 '12 at 07:53

0 Answers0