0

I am using selenium 3.5.3 and standalone selenium box. I am trying to hover an element with following code:

RemoteWebDriver driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("browserName", "firefox");
dc.setCapability("version", "55");
dc.setCapability("auth",GlobalProperties.seleniumboxAuthKey());
try {
     driver = new RemoteWebDriver(new 
URL("http://myseleniumboxurl.com/wd/hub"), dc);
}
catch (MalformedURLException e) {
    System.out.println(e);
}
driver.get("https://github.com/SeleniumHQ");
Actions action = new Actions(driver);
WebElement elem = driver.findElement(By.xpath("//a[contains(@href, '/pricing')]"));
action.moveToElement(elem).perform();

I am getting following exception: Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo

at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:220)
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:118)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.support.events.internal.EventFiringMouse.mouseMove(EventFiringMouse.java:58)
at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:59)
at org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation.call(MouseMoveToLocation.java:32)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Any possible workaround or solution please?

1 Answers1

0

In Selenium 3.5.0 mouse move not working properly. So you can use java script libraries and use a java script command to mouse move on element

  • I tried using String moveTo = "var fireEvent = arguments[0];" + "var evObj = document.createEvent('MouseEvents');" + "evObj.initEvent( 'mouseover', true, true );" + "fireEvent.dispatchEvent(evObj);"; driver.executeScript(moveTo, element); This also doesn't work. Can you please suggest? – Sujeet Kumar Sep 29 '17 at 09:57
  • No you can update the browser version and the selenium version. Now its working fine. – Amith Wijesiri Oct 12 '17 at 10:18