Selenium没有截图PhantomJS'页面状态

时间:2017-01-16 13:10:06

标签: php selenium phantomjs screenshot ghostdriver

我在运行Selenium测试时尝试从Chrome切换到PhanomJS。但由于PhantomJS的原因不明确,它失败了。

首先,这是我用PhantomJS运行第一次测试时Selenium Server输出的内容:

14:40:49.346 INFO - Executing: [new session: Capabilities [{browserName=phantomjs}]])
14:40:49.405 INFO - Creating a new session for Capabilities [{browserName=phantomjs}]
14:40:49.427 INFO - executable: /srv/http/s1/./vendor/bin/phantomjs
14:40:49.427 INFO - port: 27218
14:40:49.427 INFO - arguments: [--webdriver=27218, --webdriver-logfile=/srv/http/s1/phantomjsdriver.log]
14:40:49.427 INFO - environment: {}
PhantomJS is launching GhostDriver...
[INFO  - 2017-01-16T12:40:50.745Z] GhostDriver - Main - running on port 27218
[INFO  - 2017-01-16T12:40:51.074Z] Session [034e39e0-dbe9-11e6-8098-1bc85ede532e] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.8 Safari/534.34","webSecurityEnabled":true}
[INFO  - 2017-01-16T12:40:51.074Z] Session [034e39e0-dbe9-11e6-8098-1bc85ede532e] - page.customHeaders:  - {}
[INFO  - 2017-01-16T12:40:51.075Z] Session [034e39e0-dbe9-11e6-8098-1bc85ede532e] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.8","driverName":"ghostdriver","driverVersion":"1.1.0","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2017-01-16T12:40:51.075Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 034e39e0-dbe9-11e6-8098-1bc85ede532e
14:40:51.079 INFO - Done: [new session: Capabilities [{browserName=phantomjs}]]
14:40:51.158 INFO - Executing: [get current window handle])
14:40:51.164 INFO - Done: [get current window handle]
14:40:51.182 INFO - Executing: [set window size])
14:40:51.233 INFO - Done: [set window size]
14:40:53.219 INFO - Executing: [get: http://s1/])
14:40:54.256 INFO - Done: [get: http://s1/]
14:40:54.274 INFO - Executing: [find element: By.cssSelector: html])
14:40:54.371 INFO - Done: [find element: By.cssSelector: html]
14:40:54.387 INFO - Executing: [find element: By.cssSelector: .login-form])
14:40:54.409 INFO - Done: [find element: By.cssSelector: .login-form]
14:40:54.413 INFO - Executing: [find element: By.id: email])
[ERROR - 2017-01-16T12:40:54.673Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1484570454618
14:40:55.508 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'email'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"30","Content-Type":"application/json;charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"email\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
Command duration or timeout: 452 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=1.9.8, platform=LINUX, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.1.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 034e39e0-dbe9-11e6-8098-1bc85ede532e
*** Element info: {Using=id, value=email}
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413)
        at org.openqa.selenium.By$ById.findElement(By.java:218)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
        at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
        at com.sun.proxy.$Proxy4.findElement(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: EventFiringWebDriver
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:138)
        ... 18 more
Caused by: org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'email'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"30","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"email\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
14:40:55.510 WARN - Exception: {"errorMessage":"Unable to find element with id 'email'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"30","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"email\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
14:40:55.514 INFO - Executing: [find element: By.name: email])
14:40:55.537 INFO - Done: [find element: By.name: email]
14:40:55.559 INFO - Executing: [send keys: 2 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> name: email], [_, _, t, e, s, t, -, c, r, o, w, d, -, m, a, r, k, e, t, e, r, _, _, @, g, m, a, i, l, ., c, o, m]])
14:40:55.676 INFO - Done: [send keys: 2 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> name: email], [_, _, t, e, s, t, -, c, r, o, w, d, -, m, a, r, k, e, t, e, r, _, _, @, g, m, a, i, l, ., c, o, m]]
14:40:55.680 INFO - Executing: [find element: By.id: password])
[ERROR - 2017-01-16T12:40:55.933Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1484570455885
14:40:56.446 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'password'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"password\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
Command duration or timeout: 473 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=1.9.8, platform=LINUX, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.1.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 034e39e0-dbe9-11e6-8098-1bc85ede532e
*** Element info: {Using=id, value=password}
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413)
        at org.openqa.selenium.By$ById.findElement(By.java:218)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
        at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
        at com.sun.proxy.$Proxy4.findElement(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: EventFiringWebDriver
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:138)
        ... 18 more
Caused by: org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with id 'password'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"password\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
14:40:56.449 WARN - Exception: {"errorMessage":"Unable to find element with id 'password'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"33","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"password\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element"}}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
14:40:56.452 INFO - Executing: [find element: By.name: password])
14:40:56.468 INFO - Done: [find element: By.name: password]
14:40:56.473 INFO - Executing: [send keys: 3 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> name: password], [1, 2, 3, 4, 5, 6]])
14:40:56.563 INFO - Done: [send keys: 3 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> name: password], [1, 2, 3, 4, 5, 6]]
14:40:56.566 INFO - Executing: [find element: By.cssSelector: .login-form .submit-button])
14:40:56.620 INFO - Done: [find element: By.cssSelector: .login-form .submit-button]
14:40:56.623 INFO - Executing: [click: 4 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)]-> css selector: .login-form .submit-button]])
14:40:57.407 INFO - Done: [click: 4 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> css selector: .login-form .submit-button]]
14:40:57.421 INFO - Executing: [find element: By.cssSelector: html])
14:40:57.480 INFO - Done: [find element: By.cssSelector: html]
14:40:57.483 INFO - Executing: [find elements: By.cssSelector: .site-content .projects-table .c-checkbox])
14:40:57.540 INFO - Done: [find elements: By.cssSelector: .site-content .projects-table .c-checkbox]
14:40:57.544 INFO - Executing: [click: 6 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)]-> css selector: .site-content .projects-table .c-checkbox]])
14:40:57.665 INFO - Done: [click: 6 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> css selector: .site-content .projects-table .c-checkbox]]
14:40:57.668 INFO - Executing: [find element: By.cssSelector: .site-content .action-line .c-select])
14:40:57.727 INFO - Done: [find element: By.cssSelector: .site-content .action-line .c-select]
14:40:57.732 INFO - Executing: [click: 8 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)]-> css selector: .site-content .action-line .c-select]])
14:40:57.815 INFO - Done: [click: 8 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)] -> css selector: .site-content .action-line .c-select]]
14:40:57.819 INFO - Executing: [find element: By.cssSelector: .site-content .action-line .c-select li[data-value=take-projects]])
14:40:57.887 INFO - Done: [find element: By.cssSelector: .site-content .action-line .c-select li[data-value=take-projects]]
14:40:57.890 INFO - Executing: [click: 9 [[PhantomJSDriver: phantomjs on LINUX (034e39e0-dbe9-11e6-8098-1bc85ede532e)]-> css selector: .site-content .action-line .c-select li[data-value=take-projects]]])
14:40:58.420 WARN - Exception thrown
org.openqa.selenium.ElementNotVisibleException: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"27","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"id\":\":wdc:1484570457439\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element/%3Awdc%3A1484570457439/click"}}
Command duration or timeout: 230 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=1.9.8, platform=LINUX, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.1.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 034e39e0-dbe9-11e6-8098-1bc85ede532e
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
        at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
        at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:335)
        at com.sun.proxy.$Proxy2.click(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:348)
        at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.openqa.selenium.remote.server.KnownElements$1.invoke(KnownElements.java:64)
        at com.sun.proxy.$Proxy3.click(Unknown Source)
        at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:30)
        at org.openqa.selenium.remote.server.handler.ClickElement.call(ClickElement.java:1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:138)
        ... 21 more
Caused by: org.openqa.selenium.ElementNotVisibleException: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"27","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"id\":\":wdc:1484570457439\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element/%3Awdc%3A1484570457439/click"}}
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
14:40:58.422 WARN - Exception: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"27","Content-Type":"application/json; charset=utf-8","Host":"localhost:27218","User-Agent":"Apache-HttpClient/4.5.1 (Java/1.8.0_112)"},"httpVersion":"1.1","method":"POST","post":"{\"id\":\":wdc:1484570457439\"}","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/034e39e0-dbe9-11e6-8098-1bc85ede532e/element/%3Awdc%3A1484570457439/click"}}
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'yuri', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.13-1-ARCH', java.version: '1.8.0_112'
Driver info: driver.version: unknown
[INFO  - 2017-01-16T12:41:01.643Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-upphase starting NOW

上面我们可以看到神话

Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken

行,我不知道如何解释。我还没有设置屏幕截图。此外,它不清楚(至少对我来说)出了什么问题。所以我决定拍一张截图。为此,我写了以下测试:

<?php

namespace Tests;

use PHPUnit_Extensions_Selenium2TestCase_ScreenshotListener;

class ATest extends SeleniumTestCase
{
    function setUp()
    {
        parent::setUp();
        $this->setBrowser('phantomjs');
        $this->listener = new PHPUnit_Extensions_Selenium2TestCase_ScreenshotListener(
            base_path('tests/screenshots'));
    }

    function test()
    {
        $this->url('https://google.com');
        $this->assertContains('Equestrian', $this->title());
    }

    function onNotSuccessfulTest($e) {
        $this->listener->addError($this, $e, null);
        parent::onNotSuccessfulTest($e);
    }
}

SeleniumTestCase由我撰写并延伸PHPUnit_Extensions_Selenium2TestCase。它不会在setUptearDown中添加任何内容。

当我使用Chrome运行时(注释掉setBrowser),我看到了:

enter image description here

但是使用PhantomJS我得到(空图像):

enter image description here

0 个答案:

没有答案