0

I am trying to perform mouseHover Operation in Java but getting Below Exception

org.openqa.selenium.UnsupportedCommandException: POST /session/10089ef9-f491-4b9c-a295-d9246dd39e02/moveto did not match a known command
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'SHI58495EU1003F', ip: '192.168.0.105', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
  • Manual Step
  • Navigate to Website "http://www.fatcow.com/"
  • perform mouseHover on "create a Site" link
  • click on option "original FatCow" option.

Have I written Successfully Executable code or anything is missing? PFB the COde

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;

public class mousehover {

    WebDriver driver;

    @Test
    public void start()
    {
        System.setProperty("webdriver.gecko.driver", "C:\\Users\\rkumar\\Desktop\\geckodriver.exe");
        driver  = new FirefoxDriver();
        driver.navigate().to("http://www.fatcow.com/");
        Actions action = new Actions(driver);
        WebElement createAsite = driver.findElement(By.linkText("Create a Site"));
        WebElement original = driver.findElement(By.linkText("Original FatCow"));
action.moveToElement(createAsite).moveToElement(original).click().build().perform();        
    }
}
Rahil Kumar
  • 426
  • 8
  • 23
  • Possible duplicate of [How to perform mouseover function in Selenium WebDriver using Java?](http://stackoverflow.com/questions/17293914/how-to-perform-mouseover-function-in-selenium-webdriver-using-java) – swinkler Dec 10 '16 at 12:33
  • @swinkler : code is almost same but didn't work – Rahil Kumar Dec 10 '16 at 13:44
  • What version of firefox browser do you have installed? v3.0.0 ====== IMPORTANT CHANGES * Firefox is only fully supported at version 47.0.1 or earlier. Support for later versions of firefox is provided by geckodriver, which is based on the evolving W3C WebDriver spec, and uses the wire protocol in that spec, which is liable to change without notice. * You may wish to choose an ESR release such as 45.4.0esr or earlier. * Firefox 47.0.0 is not supported at all. – MikeJRamsey56 Dec 10 '16 at 16:27
  • My general advice is to drop back to selenium v2.53.0 and firefox browser 47.0. – MikeJRamsey56 Dec 10 '16 at 16:30
  • Note [Marionette and geckodriver are not yet feature complete. This means it does not yet offer full conformance with the WebDriver standard or complete compatibility with Selenium.](https://github.com/mozilla/geckodriver). I don't like living on the edge, even though visiting can be fun. – MikeJRamsey56 Dec 10 '16 at 16:32
  • What exactly did not work? – swinkler Dec 12 '16 at 08:12
  • 2
    Actions is not yet implemented in Selenium 3: http://stackoverflow.com/a/41114265/1512961 – Brian Jan 12 '17 at 21:02

1 Answers1

0

Mouse hover operation can be achieved with Java script executor(without action classes):

String javaScript = "var evObj = document.createEvent('MouseEvents');"
            + "evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 
0, 0, 0, false, false, false, false, 0, null);"
            + "arguments[0].dispatchEvent(evObj);";
    ((JavascriptExecutor) driver).executeScript(javaScript, hoverElement);
    assertion