MarionetteDriver: Is there an alternative command to "mouse hover" action command for Marionette

2,942 views
Skip to first unread message

awars

unread,
Jun 15, 2016, 9:08:38 AM6/15/16
to Selenium Users
We have started using MarionetteDriver but facing an issue with mouse hover action as it seems that it doesn’t support (selenium.interactions.Actions) moveto command as I am getting the following error message:

[java] org.openqa.selenium.UnsupportedCommandException: POST /session/e5f10653-ac68-0a43-84ae-630aa3e79270/moveto did not match a known command (WARNING: The server did not provide any stacktrace information)

Here is my code that works fine with ChromeDriver and FirefoxDriver but not with MarionetteDriver:

Actions action = new Actions(driver);
action.moveToElement(element).build().perform();


Is there an alternative command for moveto command that I can use in Marionette?

Your help is much appreciated,

Spec:
OS: Mac OSX
Browser: Firefox 46
Driver: Selenium v2.53
Geckodriver : 0.8.0

Regards,
Ali

⇜Krishnan Mahadevan⇝

unread,
Jun 15, 2016, 9:14:36 AM6/15/16
to Selenium Users
From the error it looks like the implementation is still not there in GeckoDriver.
You may have to resort to leveraging JavaScript to try and simulate the same operation.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/482a96fb-e3c2-4968-93b8-ed3bb6289dbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shawn McCarthy

unread,
Jun 15, 2016, 11:37:14 AM6/15/16
to Selenium Users
Actions are not implemented yet I believe. Here is a blog post which lists a few items which aren't implemented yet :
http://www.theautomatedtester.co.uk/blog/2016/selenium-webdriver-and-firefox-47.html

awars

unread,
Jun 16, 2016, 6:25:44 AM6/16/16
to Selenium Users
Thanks for the link (I will watch that).

awars

unread,
Jun 16, 2016, 6:31:26 AM6/16/16
to Selenium Users
Thanks Krishnan, I was trying to avoid using JS to simulate hover action but I will use the following code till Actions is supported by Marionette:

                Point p = element.getLocation();
                int x = p.getX();
                int y = p.getY();

                Dimension d = element.getSize();
                int h = d.getHeight();
                int w = d.getWidth();

                Robot robot = null;
                robot = new Robot();
                robot.mouseMove(x + (w / 2), y + (h / 2) + 100);
                robot.mousePress(InputEvent.BUTTON1_MASK);

For Testing

unread,
Jun 21, 2017, 11:34:53 PM6/21/17
to Selenium Users
Hi @awars

Did this work for you?
I tried this and it didn't work for me. The problem is mouse move happens but the mouse goes to some other location.
Please help me.

Thanks

BlackFrost

unread,
Jun 22, 2017, 6:24:36 PM6/22/17
to Selenium Users
Hey,

The alternative that comes to my mind is to use JavaScript to put element into focus. I'd like to put emphasis on the word "focus", as there's no way to actually move mouse cursor to an element using JavaScript. But I believe Actions.MoveToElement() does something similar just focusing the element.

1) Anyway, you may want to have a look at JS method
document.getElementById("myAnchor").focus();

And call this JS method from your test code using something like:
((IJavaScriptExecutor)driver).ExecuteScript("el.focus();", el); //el - is you IWebElement that you want to focus on

You can read some info about this method in W3C schools and also try running example code to understand how it all works: https://www.w3schools.com/jsref/met_html_focus.asp
If you try the example (https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_html_blur) code provided by W3C you'll notice that on clicking "Get focus" button your focus goes to "Visit W3Schools.com" link that potentially will be exactly the behavior you are after.

2) I think there's a serious reason for not upgrading your GeckoDriver/Selenium in your case, but out of curiosity - what's preventing you from using the latest 0.17 GeckoDriver that works with Actions class methods just fine? (https://github.com/mozilla/geckodriver/releases). Upgrading would really make your life easier :)

Cheers.
Reply all
Reply to author
Forward
0 new messages