Selenium WebDriver 3.0.1 操作 class 从 selenium-api-3.0.1.jar 中丢失,来自 Maven 存储库

Selenium WebDriver 3.0.1 Actions class missing from selenium-api-3.0.1.jar from Maven repository

我在基于 Maven 的项目中使用 Selenium WebDriver 3.0.1。此代码片段失败(未编译):

Actions myActions = new Actions(myWebDriver);

因为从 maven 下载的 selenium-api-3.0.1.jar 缺少 org.openqa.selenium.interactions.Actions class。 这是 pom.xml:

的相关部分
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>3.0.1</version>
</dependency>
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-support</artifactId>
  <version>3.0.1</version>
  <type>jar</type>
</dependency>
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-api</artifactId>
  <version>3.0.1</version>
</dependency>
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-htmlunit-driver</artifactId>
  <version>2.52.0</version>
</dependency>
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-remote-driver</artifactId>
  <version>2.31.0</version>
</dependency>

我还在pom.xml中测试了这个替代依赖:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>3.0.1</version>
</dependency>

但在这两种情况下,下载的 selenium-api 工件中都缺少 org.openqa.selenium.interactions.Actions class。

使用 grepcode.com 在 Maven 存储库中搜索 class 仅找到版本 2.47.1 或更早版本。

我直接从 http://www.seleniumhq.org/download/ url 下载了 Selenium Client & WebDriver Language Bindings zip 包,附带的 client-combined-3.0.1-nodeps.jar 文件确实包含 org.openqa.selenium.interactions.Actions class.

看来我遗漏了什么...但我真的不知道如何修复 Maven 依赖项。任何帮助都将被热情接受!

似乎 org.openqa.selenium.interactions 软件包(包括 Actions class)已移至 selenium-remote-driver

您可以直接向 selenium-remote-driver 添加依赖项,或者更简单地向 selenium-java 添加依赖项(这取决于 selenium-chrome-driver 而后者又取决于 selenium-remote-driver).我会尝试使用后一个选项,因为这也可以让您摆脱许多其他显式依赖项。