java - 无法解析导入 org.openqa.selenium.remote.CapabilityType

标签 java maven selenium

我无法在 Selenium 3.4.0 中执行以下两个导入

import org.openqa.selenium.remote.CapabilityType;  
import org.openqa.selenium.remote.DesiredCapabilities;

我对 selenium 的 maven 依赖如下:

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

我收到错误消息,例如 The import org.openqa.selenium.remote.CapabilityType cannot be resolved in Eclipse

可能是什么问题?

最佳答案

当您尝试包含以下导入时:

import org.openqa.selenium.remote.CapabilityType;  
import org.openqa.selenium.remote.DesiredCapabilities;

您已经在 pom.xml 中添加了 org.seleniumhq.seleniumorg.seleniumhq.selenium 依赖项。

现在,根据 Selenium 3.4.0 文档 here 因为你想使用 RemoteWebDriver 实现,你仍然需要下载 selenium-server-standalone.jar 来自 Selenium Download页面,然后将其放入您的资源文件夹并通过 Runtime 对其进行操作,或者将其放在其他位置并通过命令行对其进行操作。

关于java - 无法解析导入 org.openqa.selenium.remote.CapabilityType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45597914/

相关文章:

java - 在 Android 中使用 isReachable() 时出错

java - 如何在java中的每个catch block 之前注入(inject)日志语句

java - 子模块中使用的文件路径不正确

java - JasperReports无法导出PDF文件

python Selenium 元素不可见

Python Selenium 无法打开文件以标记为存储保留

java - 将通用 ArrayList 设置为零

java - Android Studio 文件菜单中没有 "Import Sample"选项

maven - 在 Maven 构建中启用 javac 警告

javascript - 如何从 selenium javascript 中返回的 findElement 中查找元素