如何修复NoClassDefFoundError:CircularOutputStream错误?

我只是为Selenium WebDriver(又名Selenium 2)为无头测试创建了一个简单的maven项目。 我在pom.xml中添加了PhantomJS驱动程序依赖项和其他依赖项:

 com.github.detro phantomjsdriver 1.2.0  

但它得到了错误:

 java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at jp.co.skygate.home.HomePageLogin.setUp(HomePageLogin.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at 

只是从pom.xml中删除PhantomJS依赖项解决了问题并且执行正常。 有人能帮我找到问题吗?

提前致谢。

最后我得到了解决方案。

添加PhantomJS v.1.2.0将selenium-remote-driver-2.53.0.jar替换为selenium-remote-driver-2.41.0.jar,因此会破坏所有内容。 现在使用V.2.41.0,

 driver = new FirefoxDriver(); 

代替

 driver = new PhantomJSDriver(caps); 

生成错误。

根据@Ripon评论 ,问题在于版本兼容性,因此Selenium Server 2.53.x应与Phantom JS 1.3.x一起使用。

这是pom.xml中应该有效的行:

  org.seleniumhq.selenium selenium-java 2.53.1 test   com.codeborne phantomjsdriver 1.3.0  

然后运行mvn dependency:tree来构建并显示该项目的依赖关系树。

如果您没有使用Maven,则需要确保在classpath所有相关的jar文件 。