硒 moveToElement() 不工作

Selenium moveToElement() is not working

测试登录后 https://www.pcbway.com/ 我想测试注销。

为此,我需要将鼠标悬停在 div 上,以便出现退出按钮。我尝试使用 Actions actions = new Actions(driver); actions.moveToElement(element).build().perform();
但它没有用。我尝试使用 javascript 执行器 JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element); 但它也没有用。我可以看到悬停通过使用 mouseout jquery(下面的屏幕截图)

我正在使用 chrome 58 和 selenium 3.4.0。

您可以尝试通过添加 class 元素在菜单打开时接收到的内容来强制打开它。

executor.executeScript("$('.nav-user-account').addClass('user-account-unfold')")

然后您可以单击菜单中的元素。