使用java 1.8 gecko驱动程序0.19和firefox 56,是否有其他方法在selenium box中进行鼠标悬停

使用java 1.8 gecko驱动程序0.19和firefox 56,是否有其他方法在selenium box中进行鼠标悬停,java,selenium,firefox,selenium-webdriver,selenium-grid,Java,Selenium,Firefox,Selenium Webdriver,Selenium Grid,使用操作将异常作为不受支持的CommandException提供 试图做这样的事情: Actions action = new Actions(driver); action.moveToElement(element).build().perform(); driver.findElement(By.linkText("All Actions")).click(); 元素是我试图悬停的webElement 我也试过: ((JavascriptExecutor) driver).execute

使用操作将异常作为不受支持的CommandException提供

试图做这样的事情:

Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
driver.findElement(By.linkText("All Actions")).click();
元素是我试图悬停的webElement

我也试过:

((JavascriptExecutor) driver).executeScript("arguments[0].focus();",element);
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
但是没有运气


我正在使用seleniumbox,并使用最新版本的seleniumbox 3.9.1。

根据您的问题,只需将鼠标悬停在元素上,您必须先等待元素可见。对于Selenium Java Client v3.9.1、ChromeDriver v2.35和Chrome v63.0,这段代码在我这方面非常有效:

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();
使现代化 根据你的问题:

您正在使用GeckoDriver v0.19和Firefox 56.x 根据跟踪日志:

您正在使用Selenium客户端v3.4.0 发行说明中明确提到:

Note that with geckodriver 0.19.0 the following versions are recommended: - Firefox 55.0 (and greater) - Selenium 3.5 (and greater)
因此,您会看到错误:

Caused by: org.openqa.selenium.UnsupportedCommandException: mouseMoveTo Build info: version: '3.4.0', revision: 'unknown', time: 'unknown
这个动作不起作用。可能的解决方案是将Firefox和GeckoDriver的版本更改为较低的稳定版本

IEDriver示例:


如果这样更改代码有帮助,请尝试:

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

行动不起作用。在使用操作时,它会给出不受支持的命令异常。我已经使用Thread.sleep5000提供了wait;我的主要目标是将鼠标悬停在一个元素上,然后单击下拉列表中的一个元素。鼠标悬停时可以看到下拉菜单,元素失去焦点后,下拉菜单消失。我想选择这一切。嗨,德班詹布,我没有改变我的问题,我只是想详细说明一下。我已经尝试了你的代码,但它不起作用。原因:org.openqa.selenium.unsupportedCommand异常:mousemovoint构建信息:版本:“3.4.0”,修订版:“未知”,时间:“未知”这是异常。代码可以在本地运行,但不能在远程运行。但我只使用3.9.1版本。我的pom.xml内容是:io.github.seleniumquery seleniumquery 0.16.0 org.seleniumhq.selenium selenium java 3.9.1 org.seleniumhq.selenium selenium server 3.9.1有其他解决方案吗?实际上,我也尝试过更改版本,但由于我使用的是seleniumbox,降级的版本有很多问题,例如打开新选项卡和sendkeys,这就是我升级版本的原因。有没有其他方法可以做到这一点?试着用点击并按住来代替悬停。这是不一样的,但如果你需要你的元素的状态和截图,这可能是一个很好的解决方案。您是否尝试使用mouseDown?尝试使用来自或此的JavaScript解决方案
Actions action = new Actions(driver);
action.moveToElement(element).moveToElement( driver.findElement(By.linkText("All Actions"))).click().build().perform();