如何修复NoClassDefFoundError:CircularOutputStream错误?

Mah*_*man 4 java headless maven phantomjs selenium-webdriver

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

<dependency>
    <groupId>com.github.detro</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.2.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

但它得到了错误:

java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(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
Run Code Online (Sandbox Code Playgroud)

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

提前致谢.

Mah*_*man 5

最后我得到了解决方案.

添加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();
Run Code Online (Sandbox Code Playgroud)

代替

driver = new PhantomJSDriver(caps);
Run Code Online (Sandbox Code Playgroud)

生成错误.

  • 所以,这是版本兼容性问题.您可以将phantomjsdriver 1.3.0与selenium-remote-driver-2.53.0一起使用 (2认同)