问题描述
我有一种情况,我必须将鼠标悬停在菜单链接上,然后单击下拉子菜单.我正在使用的代码如下:
I have a scenario where I have to hover over a menu link and click on the drop down sub menus. The code that I'm using is below:
public void changeLanguageTest() throws InterruptedException
{
WebElement LanguageMenu = driver.findElement(By.cssSelector(".change-language>button"));
action.moveToElement(LanguageMenu);
WebElement mongolianLang = driver.findElement(By.cssSelector(".change-language>ol>li:nth-child(3)>a"));
action.moveToElement(mongolianLang).click().build().perform();
Thread.sleep(3000L);
}
但是当我运行这段代码时,它失败并显示一条错误消息:-
But when I run this code, It fails with an error message :-
我也尝试了下面提到的代码,但是没有成功,并且发生了相同的错误.
I tried below mentioned code too but no success and same error occurred.
BaseClass.action.moveToElement(LanguageMenu).moveToElement(mongolianLang).click().build().perform();
我正在使用webdriver v2.53
并在FF v47.0.1
上运行它.
I'm using webdriver v2.53
and running it on FF v47.0.1
.
推荐答案
作为在此处记录的错误 geckodriver
尚未实现actions
.我们将执行的操作是现在在 W3C WebDriver standard
中定义的那些,而不是Selenium的那些
As a bug logged here geckodriver
does not yet implement actions
. The actions we will implement are those being defined right now in the W3C WebDriver standard
and not those of Selenium.
硒已经表示将提供 Selenium-to-W3C-WebDriver
填充程序采取行动,但这可能需要一些时间才能实施. geckodriver/Marionette
中的实施尚未开始.
Selenium has said they will provide a Selenium-to-W3C-WebDriver
shim for actions, but this may take some time to produce after we have made our implementation. Implementation in geckodriver/Marionette
has not yet started.
如在geckodriver
的v0.12.0中提到的 ,为 new actions API
,实施了路由,但在木偶中尚未完全实现
As mentioned here from v0.12.0 of geckodriver
, Implemented routing for new actions API
, but it too is not yet fully implemented in Marionette
您应该升级 geckodriver
.
You should upgrade your geckodriver
.
这篇关于Selenium Actions.movetoElement-org.openqa.selenium.UnsupportedCommandException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!