Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse move doesn't work on safari #1526

B8li opened this issue Nov 13, 2014 · 7 comments


Copy link

@B8li B8li commented Nov 13, 2014

I have following simple test to move the mouse over some element.

it('test on safari', function() {
    var el = element(by.css("element"));

It works on chrome and firefox, but on safari i get following message : Unknown command: mouseMoveTo.

It's running on MAC, protractor version : 1.3.1
This is the stacktrace :

    UnknownError: Unknown command: mouseMoveTo (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 2 milliseconds
    Driver info: org.openqa.selenium.safari.SafariDriver
    Capabilities [{platform=MAC, cssSelectorsEnabled=true, javascriptEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=7.0.5}]

Is this known problem or is there any workaround around this ?

Thanks in advance,


This comment has been minimized.

Copy link

@juliemr juliemr commented Nov 13, 2014


This comment has been minimized.

Copy link

@bmsoko bmsoko commented May 20, 2015

Hello! does any one have a workaround for this?


This comment has been minimized.

Copy link

@daluu daluu commented Jul 15, 2015

Except for a premade hack patch for Protractor, you can find workarounds for hover / mouse over and drag & drop in the previously referenced SafariDriver issue, specifics below. Note that the workarounds use JS code execution against browser to simulate mouse events rather than invoke native events which SafariDriver has yet to support.

For hover / mouse over (hence mouse move), see comment 4 (which then references another Selenium issue with reference to comment 60 there that has JS code snippet for the workaround)

For drag & drop, see comment 10

I've used both against SafariDriver but with Selenium WebDriver not Protractor, but that shouldn't matter.


This comment has been minimized.

Copy link

@abhirep abhirep commented Jan 21, 2016

@daluu I tried porting the code in the comment no 10 like this

function dragdrop(fromXpath, forId) {
    var LocatorFrom = element(by.xpath(ControlXpath));
    var LocatorTo =  element("forId));
    var xto=LocatorTo.getLocation().x;
    var yto=LocatorTo.getLocation().y;
    browser.executeScript("function simulate(f,c,d,e){var b,a=null;for(b in eventMatchers)if(eventMatchers[b].test(c)){a=b;break}if(!a)return!1;document.createEvent?(b=document.createEvent(a),a=='HTMLEvents\"?b.initEvent(c,!0,!0):b.initMouseEvent(c,!0,!0,document.defaultView,0,d,e,d,e,!1,!1,!1,!1,0,null),f.dispatchEvent(b)):(a=document.createEventObject(),a.detail=0,a.screenX=d,a.screenY=e,a.clientX=d,a.clientY=e,a.ctrlKey=!1,a.altKey=!1,a.shiftKey=!1,a.metaKey=!1,a.button=1,f.fireEvent('on'+c,a));return!0} var eventMatchers={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/}; " +
    "simulate(arguments[0],'mousedown',0,0); simulate(arguments[0],'mousemove',arguments[1],arguments[2]); simulate(arguments[0],'mouseup',arguments[1],arguments[2]); ",

I don't even have a slightest idea if I am doing it correctly but I am getting maximum call stack exceeded error.

Is there any working snippet that I can use for safari In protractor


This comment has been minimized.

Copy link

@daluu daluu commented Jan 21, 2016

@abhirep on brief glance, that code port you did seemingly looks ok. I've never used Protractor and the original snippet I used was for/in Java (but the language client/binding technically shouldn't matter).

To help debug the matter, have you tried running that ported snippet against another browser? If it works on others but not Safari, then it is some Protractor issue with Safari in terms of the snippet. Because I know it works for Safari via Java/WebDriver version of snippet.

Another thing to consider is what version of Safari are you testing against, along with what version of Protractor (and how that maps to which version of SafariDriver/Selenium), sometimes might have version issues. I forget what Safari version I last tested the snippet against but it sure isn't Safari 9, more likely somewhere between Safari 5-8.

FYI, for testing/debugging purposes, I believe that code snippet is also runnable outside Protractor via Safari's Error/Javascript Console. But to run it from there, you may have to adapt the code a bit. If element(), by.xpath(), are not available in console, you'll have to use their equivalents like document.getElementBy... or jQuery, etc. and you can "execute script" directly - just first define the simulate() function (by pasting it into the console and running/executing that) then call it 3x in that snippet sequence (as a single line separated by the commas) but substituting argument[n] with the actual variable for the element or x/y coordinate.


This comment has been minimized.

Copy link

@juliemr juliemr commented Dec 21, 2016

As of Safari 10, SafariDriver is now shipped by Apple with Safari (see the post at I'm closing old external safari issues because they are now obsolete.

@juliemr juliemr closed this Dec 21, 2016

This comment has been minimized.

Copy link

@daluu daluu commented Dec 22, 2016

Curious though, for interested parties/users, does this work now on Safari 10, without any patching?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants
You can’t perform that action at this time.