public static void main(String[] args) throws Exception {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "E:\\phantomjs.exe");
WebDriver driver = new PhantomJSDriver();
driver.get("http://www.google.com");
}
错误:
主线程异常:java.lang.IllegalStateException:phantomjs.binary.path能力/系统属性/PATH变量必须设置驱动程序可执行文件的路径。有关更多信息,请参见https://github.com/ariya/phantomjs/wiki。最新版本可从http://phantomjs.org/download.html下载。 在com.google.common.base.Preconditions.checkState(Preconditions.java:197) 在org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS(PhantomJSDriverService.java:236) 在org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:181) 在org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:104) 在org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:94) 在multidrivers.main(multidrivers.java:35)