2016-08-05 53 views
12

我面临与Actions类驱动程序的问题。我有这段代码行动类不与壁虎驱动程序工作

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

此前,当我使用Selenium-Java 2.43.0时,此命令工作正常。但我已升级到3.0.0-beta2,通过gecko驱动程序开始访问firefox driver

在上述指定的命令我的测试失败。我得到下面的异常

org.openqa.selenium.UnsupportedCommandException:POST /会话/ 21dfc828-a382-4622-8c61-89bc48e29744 /通过MoveTo不匹配 知命令(警告:服务器没有提供任何堆栈跟踪信息 )命令持续时间或超时:4毫秒

请帮

+0

有记录在此硒公开问题的问题。我们必须等待修复。 https://github.com/SeleniumHQ/selenium/issues/2285。这是问题。可能是我们不得不等待这个。 –

+0

截至2017年3月18日,在这个问题上,它看起来像“现在在geckodriver 0.15和Selenium 3.x中实现”,并且问题已关闭。但我仍然有一些相当大的问题与鼠标悬停仍然:/ –

回答

5

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

我很遗憾没有测试最新版本,但同时它没有任何Firefox测试运行。没有针对Firefox运行几个月结束是无法接受。

4

这是一个版本问题。 Selenium 3尚未支持Actions类驱动程序。您将不得不下载到较低版本。版本2.53.1工作正常,我与Firefox

+1

任何消息呢?这是否应该在某个时候实施,希望很快? – nostradamus

0

以下为我工作在Firefox 52.3.0 ESR和硒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); 
} 
相关问题