这是PhantomJS Session的Stack Trace。它随机地做到这一点。我看到它说:Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
。该代码与Firefox浏览器完美配合,但无头无法使用。
我在这个问题上一直在做的谷歌搜索很少,但有关PhantomJS的网页未能截取屏幕截图,而我所做的只是尝试点击一个元素。或者我误解了,实际发生的是PhantomJS正在拍摄失败的点击失败的截图?
[ERROR - 2015-06-08T16:02:30.402Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1433779350383:262 in error
Exception in thread "main" org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with xpath'//*[@id=\"linput_806867695_10_9022592247_0\"]'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"78","Content-Type":"application/json; charset=utf-8","Host":"localhost:31177","User-Agent":"Apache-HttpClient/4.3.6 (java 1.5)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"xpath\",\"value\":\"//*[@id\\u003d\\\"linput_806867695_10_9022592247_0\\\"]\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/828cd8e0-0df7-11e5-835a-03db015d40d4/element"}}
Command duration or timeout: 5.60 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'debserver', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'i386', os.version: '3.16.0-4-686-pae', java.version: '1.7.0_79'
*** Element info: {Using=xpath, value=//*[@id="linput_806867695_10_9022592247_0"]}
Session ID: 828cd8e0-0df7-11e5-835a-03db015d40d4
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{platform=LINUX, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, driverVersion=1.2.0, locationContextEnabled=false, version=2.0.1, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=false, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, webStorageEnabled=false, driverName=ghostdriver, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:449)
at org.openqa.selenium.By$ByXPath.findElement(By.java:357)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at surveymonkeybot.SurveyMonkeyBot.M6BD8DW(SurveyMonkeyBot.java:447)
at surveymonkeybot.SurveyMonkeyBot.getChoice(SurveyMonkeyBot.java:82)
at surveymonkeybot.SurveyMonkeyBot.main(SurveyMonkeyBot.java:28)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'debserver', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'i386', os.version: '3.16.0-4-686-pae', java.version: '1.7.0_79'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:136)
... 8 more
Caused by: org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with xpath '//*[@id=\"linput_806867695_10_9022592247_0\"]'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"78","Content-Type":"application/json; charset=utf-8","Host":"localhost:31177","User-Agent":"Apache-HttpClient/4.3.6 (java 1.5)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"xpath\",\"value\":\"//*[@id\\u003d\\\"linput_806867695_10_9022592247_0\\\"]\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/828cd8e0-0df7-11e5-835a-03db015d40d4/element"}}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'debserver', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'i386', os.version: '3.16.0-4-686-pae', java.version: '1.7.0_79'
Driver info: driver.version: unknown