我编写了以下代码,以使用java脚本捕获网页的整个屏幕截图。
我使用: Firefox版本: 49.0.1 Chrome版本:54.0.2840.59 m Selenium版本: 3.0.0 操作系统: Win10 64位 Java: 1.8
1476679740598 geckodriver INFO Listening on 127.0.0.1:38310
Oct 16, 2016 11:49:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1476679741083 mozprofile::profile INFO Using profile path C:\Users\VISHVA~1\AppData\Local\Temp\rust_mozprofile.h4P3qq7Ekmrz
1476679741083 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1476679741083 geckodriver::marionette INFO Connecting to Marionette on localhost:50064
1476679742059 Marionette INFO Listening on port 50064
1476679743366 Marionette INFO startBrowser 6f833edf-0ff4-4f1f-869c-1de62f8626a9
Oct 16, 2016 11:49:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.WebDriverException: Permission denied to access property "H"
Build info: version: 'unknown', revision: '350cf60', time: '2016-10-13 10:43:56 -0700'
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=9960, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 6f833edf-0ff4-4f1f-869c-1de62f8626a9
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537)
at ScreenCapture.main(ScreenCapture.java:19)
网页将向下滚动但代码会突然停止,并显示以下错误。能帮忙吗?
for (long myint : Red)
{
//...
}
答案 0 :(得分:0)
我遇到了与Selenium Web Driver 3.0.1相同的错误。 切换到版本2.53.1时,问题就消失了。
答案 1 :(得分:0)
我也遇到了这个问题,经过一些研究,我可以说这不是Selenium的问题。这是壁虎司机的问题。您可以使用chrome运行它,它可以正常工作。
答案 2 :(得分:0)
只需更新到Firefox之夜即可使用。
可以在https://www.mozilla.org/en-US/firefox/channel/desktop/(标记为Beta的那个)找到Firefox之夜。
最好使用具有最新Firefox Night版本的最新webdriver版本(开发和代码问题的所有代码和工作都集中在同步上,当然它在顺序上是有意义的更好地覆盖更新的最终用户场景。)