Using mousemove in Selenium 3 with GeckoDriver | Selenium Forum
M
Posted on 05/02/2017
Hi Ashish,

When I use MoveToElement method, my script getting failed with "org.openqa.selenium.UnsupportedCommandException".
While searching on net, I found that the Actions class methods (MoveToElement) not working in Selenium 3.

So, is there any alternative, so that I can perform Mouse Move action ?
Note: JavaScript Scroll does not help as I need mouseHover event to occur.

M
Replied on 05/02/2017

show me the code of how you're using it.


M
Replied on 07/02/2017

Here is my code, and following the code section is the error message.
[code:x5ejl168]
package util;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

public class test {

public static void main(String[] args) throws InterruptedException {


System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + "//References//geckodriver-v0.13.0-win32//geckodriver.exe";);
WebDriver driver = new FirefoxDriver();

driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

Actions act = new Actions(driver);

driver.get("https://www.victorianplumbing.co.uk/chrome-sleeving-kit-300mm");
driver.findElement(By.id("btnAdd")).click();
Thread.sleep(2000);

WebElement e = driver.findElement(By.id("lnkView"));

Action mouseHover = act.moveToElement(e).build();
mouseHover.perform();
// act.moveToElement(e).click().build().perform();

}
}

[/code:x5ejl168]

Error:
1486530060990 geckodriver INFO Listening on 127.0.0.1:1372
Feb 08, 2017 10:31:01 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1486530061399 mozprofile::profile INFO Using profile path C:\Users\dhaval\AppData\Local\Temp\rust_mozprofile.cH8qhqqVEaFP
1486530061399 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1486530061399 geckodriver::marionette INFO Connecting to Marionette on localhost:52861
1486530062091 Marionette INFO Listening on port 52861
Feb 08, 2017 10:31:03 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1486530064063 Marionette WARN Using deprecated data structure for setting timeouts
Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: POST /session/1c28c6e2-2b67-4ed0-86ee-a01fb5dc7617/moveto did not match a known command
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'VAROLOGIC-PC203', ip: '192.168.2.133', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20170125094131, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=5780, browserVersion=51.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}]
Session ID: 1c28c6e2-2b67-4ed0-86ee-a01fb5dc7617
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.interactions.MoveMouseAction.perform(MoveMouseAction.java:39)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:50)
at util.testing.main(testing.java:33)


M
Replied on 08/02/2017

use selenium 2.53, latest version has bugs in it.


M
Replied on 08/02/2017

ok. Thanks for quick response. I was in double mind that there can be such error in selenium latest version 3.0.


M
Replied on 09/02/2017

selenium 3 is only a few months old.