如何在 Java 或 Android 项目中添加 Selenium 库。导入 org.openqa 无法解析

Ste*_*ple 3 java eclipse selenium

我试图找到任何真正有效的 Selenium 教程。目前在看这个 项目没有编译。它有6个错误:

1) Firefox Driver cannot be resolved to a type
2) The import org.openqa cannot be resolved.
3) The import org.openqa cannot be resolved.
4) The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project.
5) The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files.
6) WebDriver cannot be resolved to a type.
Run Code Online (Sandbox Code Playgroud)

我的类路径中有以下内容:

byte-buddy-1.7.5.jar, 
client-combined-3.8.1-sources.jar, 
client-combined-3.8.1.jar, 
commons-codec-1.10.jar, 
commons-exec-1.3.jar, 
commons-logging-1.2.jar, 
gson-2.8.2.jar, 
guava-23.0.jar, 
httpclient-4.5.3.jar, 
httpcore-4.4.6.jar
Run Code Online (Sandbox Code Playgroud)

请帮忙!

小智 5

尝试将 selenium-java 依赖项添加到 POM.xml 中,例如:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

它对我有用!