我正在学习硒,我只是从网站上复制了一个简单的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
错误:
线程“主”中的异常java.lang.NoClassDefFoundError:
org.openqa.selenium.firefox.FirefoxBinary.org.openqa.selenium.firefox.org.openqa.selenium.firefox上的org / openqa / selenium / remote / internal / CircularOutputStream。 org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:95)的FirefoxBinary。(FirefoxBinary.java:55),Sel.OpenGoogle.main(OpenGoogle.java:6)的原因:java.lang.ClassNotFoundException:org java.net的.openqa.selenium.remote.internal.CircularOutputStream(java.net.URLClassLoader.findClass(未知源),sun.misc.Launcher $ AppClassLoader.loadClass(未知源)(java.lang.ClassLoader.loadClass(未知源)) .lang.ClassLoader.loadClass(未知来源)...还有4个
我的代码:
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");
}
}
添加硒远程驱动程序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文件并加载新的jar文件。注意不要删除JRE系统库。然后,一切都会正常。顺便问一下,您使用的是哪种Firefox浏览器?我正在使用47.0.1,好处是您不必使用壁虎驱动程序。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句