我正在尝试使用phantomJS登录到DEV PAYPAL网站。
从弹出窗口点击登录按钮,我看到以下错误信息
Exception in thread "main" org.openqa.selenium.WebDriverException: Error Message => 'Click succeeded but Load Failed. Status: 'fail''
caused by Request => {"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"27","Content-Type":"application/json; charset=utf-8","Host":"localhost:55458"},"httpVersion":"1.1","method":"POST","post":"{"id":":wdc:1371206664100"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/5e4434e0-d4df-11e2-941a-e76337e4cf88/element/%3Awdc%3A1371206664100/click"}
Command duration or timeout: 7.12 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_25-ea'
Session ID: 5e4434e0-d4df-11e2-941a-e76337e4cf88
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{platform=XP, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, driverVersion=1.0.3, locationContextEnabled=false, version=1.9.0, databaseEnabled=false, cssSelectorsEnabled=true, handlesAlerts=false, browserConnectionEnabled=false, proxy={proxyType=direct}, webStorageEnabled=false, nativeEvents=true, driverName=ghostdriver, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at com.selenium.wipro.Phantomsample.ExampleScenario.main(ExampleScenario.java:114)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_25-ea'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)
... 4 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Error Message => 'Click succeeded but Load Failed. Status: 'fail''
caused by Request => {"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"27","Content-Type":"application/json; charset=utf-8","Host":"localhost:55458"},"httpVersion":"1.1","method":"POST","post":"{"id":":wdc:1371206664100"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/5e4434e0-d4df-11e2-941a-e76337e4cf88/element/%3Awdc%3A1371206664100/click"}
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_25-ea'
Driver info: driver.version: unknown
我是通过JAVA WebDriver使用phantomjs 1.9.0 .
我已经做了很多阅读,并尝试设置以下功能
DesiredCapabilities PJScapabilities = DesiredCapabilities.phantomjs();
PJScapabilities.setCapability("takesScreenshot", true);
PJScapabilities.setCapability("secureSsl", true);
PJScapabilities.setCapability("acceptSslCerts", true);
PJScapabilities.setCapability("javascriptEnabled", true );
//Need to set an environmental variable that points to the location of the PhantomJS Binary for GhostDriver support
//D:workspacephantomjs
PJScapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:\workspace\phantomjs\phantomjs.exe");
这是GhostDriver的一个bug。看到:
https://github.com/detro/ghostdriver/issues/202