测试登录后https://www.pcbway.com/我想测试注销。
为了做到这一点,我需要将鼠标悬停在 div 上,以便出现注销按钮。我尝试使用
Action actions = new Actions(driver);
actions.moveToElement(element).build().perform();
但它不起作用。我尝试使用 javascript 执行器
JavascriptExecutor 执行器 = (JavascriptExecutor) 驱动程序; executor.executeScript("arguments[0].click();", element);
但它也不起作用。我可以看到悬停是通过使用 mouseout jquery 来实现的(下面的屏幕截图)
我正在使用 chrome 58 和 selenium 3.4.0。
最佳答案
您可以尝试通过添加菜单打开时元素接收的类来强制打开它。
executor.executeScript("$('.nav-user-account').addClass('user-account-unfold')")
然后您可以单击菜单中的元素。
关于java - Selenium moveToElement() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44509721/