13

I am facing a problem with Actions class driver. I have this piece of code

Actions act= new Actions(d1);
act.moveToElement(d1.findElement(By.xpath("path of the element")).build().perform();

Previously when i am using Selenium-Java 2.43.0 , this command is working fine. But i have upgraded to 3.0.0-beta2, started access firefox driver through gecko driver.

At the above specified command my test is failing . Am getting the below exception

org.openqa.selenium.UnsupportedCommandException: POST /session/21dfc828-a382-4622-8c61-89bc48e29744/moveto did not match a known command (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 4 milliseconds

Please help

4

3 回答 3

5

在他们解决这个问题之前,临时的、可怕的、令人沮丧的答案是恢复到 Selenium 和 Firefox 的工作版本。带有 Firefox 45.0.2 的 Selenium 2.53.0 仍在工作: https ://ftp.mozilla.org/pub/firefox/releases/45.0.2/

我很遗憾没有针对最新版本进行测试,但同时它胜过根本没有运行任何 Firefox 测试。连续几个月不运行 Firefox 是不可接受的。

于 2016-12-07T16:36:41.200 回答
5

这是一个版本控制问题。Selenium 3 尚不支持 Actions 类驱动程序。您必须下载到较低版本。2.53.1 版适用于我的 Firefox

于 2016-12-13T05:28:40.050 回答
0

以下适用于 Firefox 52.3.0 ESR 和 Selenium 3.5.1

public void mouseRightClickAndSelectOption(By locator, By contextMenuOption){
    clickElement(locator);
    String script = "var evt = document.createEvent('MouseEvents');" + "evt.initMouseEvent('contextmenu',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" + "arguments[0].dispatchEvent(evt);";

    try {
        ((JavascriptExecutor) driver).executeScript(script, getElement(locator));
    } catch (Exception ignored) {
    }
    clickElement(contextMenuOption);
}


public WebElement getElement(By locator) {
    fluentWait(locator);
    return driver.findElement(locator);
}
于 2017-08-23T08:35:56.787 回答