Java 导入 org.openqa 无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47757068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The import org.openqa cannot be resolved
提问by Steve Staple
I am trying to find any Selenium Tutorials that actually work. Currently looking at this oneThe project does not compile. It has 6 errors:
我试图找到任何真正有效的 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.
I have the following in my classpath:
我的类路径中有以下内容:
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
Please help!
请帮忙!
回答by karthick
The problem should be in configuring your POM.xml
问题应该是在配置你的 POM.xml
Check the following,
检查以下内容,
- Did you add all required dependencies in POM file
- what version of firefox are you using if latest vesion try downloading 5 versions older
- 您是否在 POM 文件中添加了所有必需的依赖项
- 如果最新版本尝试下载 5 个旧版本,您使用的是哪个版本的 Firefox
I can help you if more details are provided write to [email protected]
如果提供更多详细信息,我可以帮助您写信至 [email protected]
回答by Hiten
回答by Jignesh
Selenium jar has to be added to the project to identify the interface org.openqa.selenium.WebDriver
Selenium jar 必须添加到项目中以识别接口 org.openqa.selenium.WebDriver
Selenium download link: http://www.seleniumhq.org/download/
Selenium 下载链接:http: //www.seleniumhq.org/download/
回答by user1953366
I stumbled upon this, although the question is half a year old, here is what fixed it for me:
我偶然发现了这个问题,虽然这个问题已经有半年历史了,但这是为我解决的问题:
At: https://saucelabs.com/resources/articles/getting-started-with-webdriver-selenium-for-java-in-eclipseit is asked to add zip file itself to executable, but unfortunately, at least my eclipse was not able to pick import. So I unzipped it and added all the jar files. There are jar files inside libs as well, which also were needed to be added.
在:https: //saucelabs.com/resources/articles/getting-started-with-webdriver-selenium-for-java-in-eclipse它被要求将 zip 文件本身添加到可执行文件中,但不幸的是,至少我的 eclipse 是无法选择进口。所以我解压了它并添加了所有的 jar 文件。libs里面也有jar文件,也需要添加。
Secondly, although not asked here, but path to exe also needs to be specified as mentioned here: Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property
其次,虽然这里没有问,但也需要指定 exe 的路径:Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property
More precisely line which needs to be added is:
需要添加的更准确的行是:
System.setProperty("webdriver.gecko.driver", path/to/geckodriver.exe");
This worked for me. Hope it helps someone.
这对我有用。希望它可以帮助某人。
回答by ADhawan
Try adding the selenium-java dependency to your POM.xml for example:
尝试将 selenium-java 依赖项添加到 POM.xml 中,例如:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.0</version>
</dependency>
It worked for me!
它对我有用!
回答by Maheep
I was getting Error
我收到错误
" org.openqa.selenium.webdriver can't be resolved. "
“ org.openqa.selenium.webdriver 无法解析。”
The solution is :
解决办法是:
Add Selenium Jar files to your Java package or Project. it can be done via Adding External jar files in build path option of package and project .
将 Selenium Jar 文件添加到您的 Java 包或项目中。它可以通过在包和项目的构建路径选项中添加外部 jar 文件来完成。