在selenium webdriver中运行moveToElement()方法时出错?

Ris*_*ain 5 java eclipse selenium selenium-webdriver

我对selenium很新,当我在Eclipse(Java)中为Selenium WebDriver运行下面的代码时,我遇到了这个异常:

"线程中的异常"主"org.openqa.selenium.UnsupportedCommandException:mouseMoveTo"

这是代码:

    WebDriver driver = new FirefoxDriver();
    driver.get("http://newtours.demoaut.com/");
    WebElement myElement = driver.findElement(By.cssSelector("input[name=userName]"));

    Actions myAction = new Actions(driver);
    myAction.moveToElement(myElement)
        .click()
        .keyDown(myElement, keys.SHIFT)
        .sendKeys(myElement, "test")
        .keysUp(myElement, keys.SHIFT)
        .(myElement)
        .contextClick()
        .build()
        .perform();
Run Code Online (Sandbox Code Playgroud)

是什么导致这个错误?

感谢致敬.

小智 5

新版本的FirefoxDriver存在一个已知问题,即GeckoDriver,它不支持Action类,请参阅:

Selenium web驱动程序moveToElement(Actions)使用木偶驱动程序抛出错误?

https://github.com/SeleniumHQ/selenium/issues/3348

没有更多的信息,我认为这也是你的问题.如果您需要使用FF进行测试,请使用ChromeDriver中的旧版本或Chrome