phantomjs不适用于selenium java

时间:2016-03-14 13:04:05

标签: java selenium selenium-webdriver phantomjs

我正在使用Selenium 2.44.0和PhantomJS 1.9.8。我的代码:

DesiredCapabilities c = new DesiredCapabilities();
c.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "<url to phantomjs.exe>");
WebDriver w = new PhantomJSDriver(c);

错误:

  

NoClassDefFoundError:org / openqa / selenium / browserlaunchers / Proxies

我该怎么办?

1 个答案:

答案 0 :(得分:2)

Selenium 2.44.0已经很老了(October 2014),而PhantomJS 1.9.x也是pretty well obsolete

然而,2.44.0 / PhantomJS不兼容性已有详细记载:

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8088 https://github.com/detro/ghostdriver/issues/397

solution was provided in 2.45.0带有更新的PhantomJS驱动程序(即Selenium Java代码,不对应用程序进行任何更改)。

所以实际需要做的就是升级到2.45.0。