Mouse actions Selenium WebDriver moveToElement does not raise a mouseout event in Firefox Linux

I am trying to check the tooltip on my webpage using Selenium WebDriver with Firefox 19.
I'm basically trying to use mouse actions to hover over an element with a tooltip attached to check if a tooltip is displayed and hover over another item to make sure the tooltip is hidden. The first operation works fine, but when hovering over another element, the tooltip remains visible. This problem does not occur when manually checking a web page.
Has anyone else encountered this problem before? I am using Ubuntu 12.04.

+4
source share
4 answers

The Advanced Actions API seems to rely on its own events, which are disabled by default in the Linux version of Firefox. Therefore, they must be explicitly included in the WebDriver instance.

FirefoxProfile profile = new FirefoxProfile(); //explicitly enable native events(this is mandatory on Linux system, since they //are not enabled by default profile.setEnableNativeEvents(true); WebDriver driver = new FirefoxDriver(profile); 

In addition, in my case, I needed to upgrade WebDriver to version 2.31, since the hover ( moveToElement ) action did not work properly at 2.30, even with explicit events enabled. Tested with version 2.31 of WebDriver and Firefox versions 17 and 19 on Linux. For more information you can check this link:
http://code.google.com/p/selenium/wiki/AdvancedUserInteractions#Native_events_versus_synthetic_events

+5
source

I also ran into this problem with Selenium 2.30 on Firefox 19. It works fine on FF 18.2.

+1
source

This is a simple but convenient method with a javascript call that will throw a mouseout () event depending on which one you specify (I prefer to pass them using By, but you can change this to whatever you like.

I had a problem with Chrome where the tooltips refused to close once, and then closed the other click events, causing them to fail. This method saved the day in this case. Hope this helps someone else!

  /** * We need this to close help text after selenium clicks * (otherwise they hang around and block other events) * * @param by * @throws Exception */ public void javascript_mouseout(By by) throws Exception { for (int i=0; i<10; i++) { try { JavascriptExecutor js = (JavascriptExecutor)driver; WebElement element = driver.findElement(by); js.executeScript("$(arguments[0]).mouseout();", element); return; } catch (StaleElementReferenceException e) { // just catch and continue } catch (NoSuchElementException e1) { // just catch and continue } } } 

You can call it after any type of click () event, for example:

 By by_analysesButton = By.cssSelector("[data-section='Analyses']"); javascript_mouseout(by_analysesButton); 

Fyi, mine is trying 10x through a for loop with try / catch, because our application tends to chrome outdated elements with Chrome, so if you don't have this problem, the method will be significantly reduced.

+1
source

I had the same problem. At first I used the moveToElement() method without perform() . Then I added the Firefox Profile using setEnableNativeEvents , but it still didn't work for me. Finally, I solved this problem this way (just adding perform() :

  WebElement username = driver.findElement (By.id ("username"));
 Actions actions = new Actions (driver);
 actions.moveToElement (username) .perform ();
 WebElement tooltip = driver.findElement (By.id ("tooltip"));
 tooltip.isDisplayed (); 

and it works great.

-1
source

All Articles