Specs: Windows 7; selenium 2.39.0; Java - Eclipse
I'm currently using Selenium to test a webApp through three different browsers (Chrome, IE9 and Firefox). The webApp has a menu bar, and there are located dropdown menus (classic). I need to set the mouse over one item of that menu bar and wait for a dropdown menu to appear, then I need to click in one of the dropdown menu items.
My code:
WebElement div_menu = driver.findElement(By.xpath("//div[text() = 'Trigger of the dropdown menu']"));
WebDriverWait wait = new WebDriverWait(driver, 300);
Actions builder = new Actions(driver);
builder.moveToElement(div_menu).build().perform();
WebElement item_to_click = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Link_inside_the_dropdown_menu")));
item_to_click.click();
The funny stuff occurs when I start the test. (FYI Browsers come up one by one, that is to say, all tests are performed for one browser before going on with other one, not threaded.)
If the mouse pointer is over the browser (because they are started not full maximized) at the time the tests are performed, then here are the results:
- Chrome: div_menu seems to get the mouseover (because of a css style change), but for too short, so that dropdown menu never appears
- IE9: throws this exception: org.openqa.selenium.ElementNotVisibleException: Cannot click on element, but mainly, div_menu gets the mouseover, so dropdown menu is displayed. In spite of this, item_to_click it's not clicked at all (btw, I don't think the exception is the issue cause). And besides, it's like an invisible mouse keep laying over the div_menu, because when I move the real mouse, dropdown menu blinks as if div_menu lose the hover and get it back every time I stop moving the real mouse.
- Firefox: Works as it's supposed to.
Now, let's see what happens when I left the mouse outside the browser window.
- Chrome: works
- IE9: works
- Firefox: div_menu seems to get the mouseover (because of a css style change), but for too short, so that dropdown menu never appears
As you can see, the code is the same for the three of the browsers. The funny variable here is the mouse_in_browser and mouse_out_browser. I can't imagine what the problem could be. If you need any extra info, please don't hesitate.
Thank you very much in advance!