theintern / leadfoot

A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.
Other
170 stars 24 forks source link

moveMouseTo() is failing when running the tests using geckodriver #111

Closed eusebiuplosnita closed 5 years ago

eusebiuplosnita commented 7 years ago

Hi! So I'm running some tests against firefox using geckodriver and when I'm calling moveMouseTo() I'm getting the following Exception:

Executing: [mousemove: 7 false]) WARN - Exception thrown org.openqa.selenium.UnsupportedCommandException: mouseMoveTo Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121' Driver info: driver.version: RemoteWebDriver

I've found a similar question about hovering on an element and I managed to make moveMouseTo() work with geckodriver by executing the code from moveMouseTo function like we had the mouse events broken, so I just commented that 'if' related to brokenMouseEvents

`//if (this.capabilities.brokenMouseEvents) {

if(element){ ................. } else{ ................ } //}` But doing this breaks the scrolling, since moveMouseTo() can be used also to scroll for an element and also we cannot use it since the moveMouseTo() function is defined in node modules, and it will fail when we try to run the tests in Jenkins since Jenkins is running npm install every time it starts a new build. Another idea, I think, can be building a wrapper function to treat the case when we're running against Firefox, and in that case we should execute another code, and for the other browsers we can call moveMouseTo(), but in this case I'm not sure how to fix the scrolling issues for firefox. Does anyone have any idea about how can I fix this? Thanks!

jason0x43 commented 7 years ago

Which versions of Firefox and geckodriver are you using?

eusebiuplosnita commented 7 years ago

Firefox ESR 52.1.2 (64-bit) , geckodriver v0.16.1.

eusebiuplosnita commented 7 years ago

I've updated the selenium server to 3.4.0 and geckodriver to 0.18.0, but mouse events are still failing when running against firefox. @jason0x43 any idea if this will be fixed?

jason0x43 commented 7 years ago

The Selenium moveto command, which is what moveMouseTo typically uses, isn't part of W3C WebDriver. WebDriver uses an Actions API, which Firefox and geckodriver at least partially implement, but we haven't added to Leadfoot yet since the spec is a bit...vague.

Until then, Firefox will need to stick with simulated events. Currently it disables the Selenium mouse commands (and uses simulated mouse events) for Firefox 49-51. We'll release a new point release of Leadfoot shortly that does this for all Firefox >= 49. Note that you'll need feature tests to be enabled (i.e., don't set fixSessionCapabilities to false).

You can also disable the Selenium mouse commands in your tests now by setting the brokenMouseEvents capability on the remote before any mouse-related tests run:

registerSuite({
    name: 'a suite',

    before: function () {
        this.remote.session.capabilities.brokenMouseEvents = true;
    },

    ...
});
jason0x43 commented 5 years ago

This error was resolved in 547b13, set brokenMouseEvents for FF 49+