java - selenium 3.3.1 中的 Actions 类已弃用,使用 contextClick 寻找解决方案

标签 java selenium selenium-webdriver

我在 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/

相关文章:

java - 根据选定的字符数拆分 ArrayList 中的字符串

java - HQL IN 子句是否只接受有限数量的值(MySQL 数据库)?

python - 如何获取URL缩短页面的结果值?

angularjs - 使用 Protractor 运行 e2e 测试用例时显示光标移动

python - 如何使用 Selenium 点击 'Show More' 按钮

java - Selenium Webdriver 和 TestNG 的图形报告

Java、多态性、静态类型和 "QueryInterface"模式

java - Spring Boot 使用自定义表进行身份验证

python - 使用 Python 教程进行测试驱动开发 : Error trying to open Firefox with Selenium on MacOSX

java - 如何使用 Java 和 Selenium 动态映射元素