0

Using Actions is giving exception as unsupportedCommandException.

Tried to do something like this:

Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
driver.findElement(By.linkText("All Actions")).click();

Element is the webElement which I tried to hover.

Tried this also:

((JavascriptExecutor) driver).executeScript("arguments[0].focus();",element);
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);

But no luck.

I am working with seleniumbox and using latest version of selenium 3.9.1.

Jack
  • 121
  • 3
  • 15
user892077
  • 33
  • 9

3 Answers3

1

As per your question only to Mouse Hover an element first you have to wait for the element to be visible. With Selenium-Java Client v3.9.1 , ChromeDriver v2.35 and Chrome v 63.0 this block of code works perfect at my end :

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath_of_element")));
Actions action = new Actions(driver);
action.moveToElement(element).perform();

Update

As per your question :

  • You are using GeckoDriver v0.19 and Firefox 56.x

As per the trace logs :

  • You are using Selenium Client v3.4.0

3.4.0

The Release Notes of Geckodriver v0.19.0 (2017-09-16) clearly mentions :

Note that with geckodriver 0.19.0 the following versions are recommended: - Firefox 55.0 (and greater) - Selenium 3.5 (and greater)

Hence you see the error :

Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo Build info: version: '3.4.0', revision: 'unknown', time: 'unknown
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Action is not working. On Using actions, it gives unsupportedcommandexception. I have already provided wait using Thread.sleep(5000); – user892077 Feb 20 '18 at 10:06
  • My main aim is to hover over an element and then click on an element which comes in drop down . Drop down is visible on mouse hover and disappers after element loses focus. – user892077 Feb 20 '18 at 10:09
  • Hi DebanjanB, I didnt change my question, i just tried to elaborate more. I have already tried your code and it is not working. – user892077 Feb 20 '18 at 11:07
  • Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' This is the exception. Code works on local but not on remote. – user892077 Feb 20 '18 at 11:10
  • But I am using 3.9.1 version only. My pom.xml contents are : io.github.seleniumquery seleniumquery 0.16.0 org.seleniumhq.selenium selenium-java 3.9.1 org.seleniumhq.selenium selenium-server 3.9.1 – user892077 Feb 20 '18 at 11:34
  • Updated my Answer with all the help I can afford from my side. Good luck. – undetected Selenium Feb 20 '18 at 11:42
  • @user892077 Are you using eclipse? Try to `right-click` on your project. Then select `Maven -> Update Project`. Also, make sure you removed any libraries you added manually which might override libraries downloaded by maven dependencies. – Fenio Feb 20 '18 at 14:15
  • @RafałLaskowski Yes I am using eclipse. Version is neon . and I have updated maven project also but it is giving exception. – user892077 Feb 21 '18 at 04:21
  • @user892077 Were you able to find a solution to this problem? I am facing the same issue while running on sauce labs. In my local I don't see a problem because I am using 3.7.1 but Sauce uses 3.4.0 by default. – Harish Talanki Apr 05 '18 at 21:56
0

The Action doesn't work. The possible solution is to change the version of Firefox and GeckoDriver to lower (Stable version).

Example for IEDriver:

selenium-standalone install --version=2.47.0 --drivers.ie.version=2.53.1

selenium-standalone start --version=2.47.0 --drivers.ie.version=2.53.1
Jack
  • 121
  • 3
  • 15
  • Any other solution ? Actually I tried changing version also, but as I am using seleniumbox , downgraded version is having many problems such as opening a new tab and sendkeys, that is why I have upgraded the version. Is there any alternate way of doing this – user892077 Feb 20 '18 at 11:09
  • Try to use click and hold insted of hover. It's not the same but if you need the state of your element and take screenshot that it could be a good solution. Did you try to use mouseDown ? – Jack Feb 20 '18 at 13:32
  • Try to use this JavaScript solution from [Stackoverflow](https://stackoverflow.com/questions/17226676/how-do-i-simulate-a-mouseover-in-pure-javascript-that-activates-the-css-hover) or this [JQuery](https://stackoverflow.com/questions/11038638/simulate-hover-in-jquery) – Jack Feb 20 '18 at 13:43
0

Try if changing the code like this helps:

Actions action = new Actions(driver);
action.moveToElement(element).moveToElement( driver.findElement(By.linkText("All Actions"))).click().build().perform();
Sijin
  • 138
  • 9