Reputation: 1345
After searching everywhere, I cannot seem to find a solution for getting mouseover events to work on with Firefox 16.0.2 and Selenium 2.28 on Mac OSX (I believe this is supposedly a problem specific to Mac OSX but this code should work on a Windows machine). I have the following which hovers over objectOnScreen which should reveal somethingElseOnScreen:
//set enable native events is suggested by another post to make these native events work
FirefoxProfile prof = new FirefoxProfile();
prof.setEnableNativeEvents(true);
WebDriver driver = new FirefoxDriver(prof);
// Hover over objectOnScreen which should reveal somethingElseOnScreen
Action builder;
Actions hover = new Actions(driver);
WebElement objectOnScreen = driver.findElement(By.xpath("//..."))
hover.moveToElement(objectOnScreen);
builder = hover.build();
builder.perform();
// Click something new that should appear on screen
By somethingElseOnScreen = By.xpath("//...");
WebDriverWait wait = new WebDriverWait(driver, 5L);
wait.until(ExpectedConditions.visibilityOfElementLocated(somethingElseOnScreen));
driver.findElement(somethingElseOnScreen).click();
This code works in Chrome but not in Firefox. In Firefox, somethingElseOnScreen never appears (I get a NoSuchElementException for the wait.until... line), and when I watch the browser I never see the hover working.
I've also tried these 2 things but neither fixes the issue:
Does anyone have a workaround for this issue?
Thank you.
Upvotes: 1
Views: 5845
Reputation: 7372
My workaround was to manually change the css display
property of the element to inline
(or block
- depending on your HTML code) that is hidden and should appear on "mouseover" (or call the JavaScript that adds the needed element on the same even - depending on your HTML code).
I can tell you specifically what code you can write, if you can tell me 3 things:
mouseover
mouseover
Upvotes: 1