导入org.openqa无法解析

时间:2017-12-11 16:20:20

标签: java eclipse selenium

我正在尝试找到实际可行的任何Selenium教程。 目前正在查看this one 该项目无法编译。它有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

请帮忙!

7 个答案:

答案 0 :(得分:0)

问题应该在于配置POM.xml 检查以下内容 1.您是否在POM文件中添加了所有必需的依赖项 2.如果最新的版本尝试下载5个旧版本

,您使用的是哪个版本的Firefox

如果提供更多详细信息,我可以帮助您 写信给karthickautomationtester@gmail.com

答案 1 :(得分:0)

您必须在项目中添加 selenium jar 或maven。 你可以从here找到硒罐。

这些将解决您的错误。

答案 2 :(得分:0)

必须将Selenium jar添加到项目中以识别接口org.openqa.selenium.WebDriver

Selenium下载链接:http://www.seleniumhq.org/download/

答案 3 :(得分:0)

我偶然发现了这个问题,尽管这个问题已经有半年了,但以下是为我解决的问题:

在:https://saucelabs.com/resources/articles/getting-started-with-webdriver-selenium-for-java-in-eclipse,要求将zip文件本身添加到可执行文件中,但不幸的是,至少我的日食无法选择导入。因此,我将其解压缩并添加了所有jar文件。库中也有jar文件,这些文件也需要添加。

第二,尽管这里没有要求,但也需要按照以下说明指定exe的路径:Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property

更准确地说,需要添加的行是:

System.setProperty("webdriver.gecko.driver", path/to/geckodriver.exe");

这对我有用。 希望对别人有帮助。

答案 4 :(得分:0)

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

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

对我有用!

答案 5 :(得分:0)

我收到错误消息“ org.openqa.selenium.webdriver无法解决。

解决方案是:

将Selenium Jar文件添加到Java包或Project中。可以通过在package和project的build path选项中添加External jar文件来完成。

  • 马希普

答案 6 :(得分:0)

在移动和整理机器中的文件和文件夹期间,我将项目的所有jar移到了另一个路径,并且遇到了项目中的错误,然后从正确的路径中添加了它们,并删除了指向以前的位置。

但是仍然过了一段时间,我仍然收到了问题“导入org.openqa无法解决”中提到的所有错误

然后我尝试从构建路径中删除jar,然后再次添加它们,它对我有用。问题是硒罐绑定。