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

新手上路,请多包涵

我试图找到任何实际有效的 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.

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

 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

请帮忙!

原文由 Steve Staple 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 861
1 个回答

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

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

它对我有用!

原文由 ADhawan 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题