【发布时间】:2017-06-07 13:15:58
【问题描述】:
我正在学习 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
错误:
线程“main”中的异常 java.lang.NoClassDefFoundError:
org/openqa/selenium/remote/internal/CircularOutputStream 在 org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59) 在 org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95) 在 Sel.OpenGoogle.main(OpenGoogle.java:6) 引起: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.CircularOutputStream 在 java.net.URLClassLoader.findClass(未知来源)在 java.lang.ClassLoader.loadClass(Unknown Source) 在 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 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");
}
}
添加 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)
【问题讨论】:
-
是的,我右键单击我的项目,然后添加了 jar 文件
-
能否也添加 selenium 远程驱动 jar 并再次测试。 mvnrepository.com/artifact/org.seleniumhq.selenium/…
-
添加远程驱动程序后出现此错误。更新OP
-
你看到这个错误了吗? “在 PATH 中找不到 firefox 二进制文件。请确保已安装 firefox。” Firefox 是否正确安装?
-
你能试试这个帖子下的解决方案吗:stackoverflow.com/questions/14723081/… or stackoverflow.com/questions/20950748/…
标签: java selenium firefox selenium-webdriver automated-tests