我已经尝试了很多,但我没有得到任何解决方案如何处理page.onError,代码如下 -
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setJavascriptEnabled(true);
desiredCapabilities.setCapability("takesScreenshot", false);
WebDriver driver = new PhantomJSDriver(desiredCapabilities);
我收到以下错误 -
[错误 - 2017-08-09T06:00:16.732Z]会议 [db2e4bf0-7cc7-11e7-a9b1-81e10abf02db] - page.onError - msg: TypeError:null不是对象(评估 '的document.getElementById(" IMG&#34)。SRC =图像[X]&#39)
phantomjs://platform/console++.js:263错误[错误 - 2017-08-09T06:00:16.733Z]会议 [db2e4bf0-7cc7-11e7-a9b1-81e10abf02db] - page.onError - stack:
答案 0 :(得分:0)
要与Selenium 3.4.0
合作PhantomJS 2.1.1
,您需要提供PhantomJS binary
到System.setProperty
命令的绝对路径,如下所示:
File src = new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path", src.getAbsolutePath());
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setJavascriptEnabled(true);
desiredCapabilities.setCapability("takesScreenshot", false);
WebDriver driver = new PhantomJSDriver();
driver.get("https://www.facebook.com/");
System.out.println("Facebook Page Loaded");