gpt4 book ai didi

java - 简单java代码中的Selenium错误

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:23 24 4
gpt4 key购买 nike

我正在学习selenium,我刚刚从网站复制了一个简单的java代码并尝试运行它。但它给了我以下错误。请帮我修复它。

安装的文件:

 1. Selenium api 2.44.0
2. Selenium firefox driver 2.44.0
3. Seleinium server stand alone 2.53.1
4. Selenium support 2.44
5. Firefox version - 35.1.0

错误:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/openqa/selenium/remote/internal/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95) at Sel.OpenGoogle.main(OpenGoogle.java:6) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.CircularOutputStream at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 4 more

我的代码:

package Sel;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenGoogle {
public static void main(String args[]){
WebDriver driver=new FirefoxDriver();
System.out.println("Hello Google...");
driver.get("http://google.com");
}
}

添加selenium远程驱动2.4.4后出错

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'PC', ip: '192.168.1.2', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:72)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:59)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:55)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Sel.OpenGoogle.main(OpenGoogle.java:6)

最佳答案

@Stack Mark 从此链接下载适用于 java 的 selenium 2.53

http://selenium-release.storage.googleapis.com/index.html?path=2.53/

删除所有当前安装的 jar 文件并加载新的。注意不要删除JRE系统库。然后一切都会正常进行。顺便问一下,您使用的是哪款火狐浏览器?我使用的是47.0.1好处是您不必使用 gecko 驱动程序。

关于java - 简单java代码中的Selenium错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41799402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com