我在 Selenium 2.44.0 上创建了自动化代码
以下代码可以正常工作
import org.openqa.selenium.interactions.Actions;
Actions action = new Actions(driver).contextClick(element);
action.build().perform();
但是现在当我尝试升级到 Selenium 3.3.1 版本时出现错误。
在重要声明附近出现以下错误:
The import org.openqa.selenium.interactions.Actions cannot be resolved
contextClick 附近出现以下错误:
Multiple markers at this line
Actions cannot be resolved to a type
Actions cannot be resolved to a type
当我查找文档时发现 Actions 类已被弃用,不知道如何执行右键单击来获取上下文菜单。
最佳答案
刚刚尝试使用selenium-server-standalone-3.3.1.jar,它工作得很好。
Actions 类在 Selenium 3.3.1 中仍然存在,因为 Selenium 3.3.1 Change Log 中没有提及它的弃用。 .
您可以从 SeleniumHQ 重新下载最新的 selenium 绑定(bind)吗? ,然后重新运行您的脚本。
关于java - selenium 3.3.1 中的 Actions 类已弃用,使用 contextClick 寻找解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43381026/