gpt4 book ai didi

java - Selenium moveToElement() 不起作用

转载 作者:行者123 更新时间:2023-12-02 12:54:01 26 4
gpt4 key购买 nike

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

为了做到这一点,我需要将鼠标悬停在 div 上,以便出现注销按钮。我尝试使用 Action actions = new Actions(driver);
actions.moveToElement(element).build().perform();

但它不起作用。我尝试使用 javascript 执行器
JavascriptExecutor 执行器 = (JavascriptExecutor) 驱动程序; executor.executeScript("arguments[0].click();", element);
但它也不起作用。我可以看到悬停是通过使用 mouseout jquery 来实现的(下面的屏幕截图)enter image description here

我正在使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com