拒绝访问属性"H"的权限. [英] Permission denied to access property "H"

查看:190
本文介绍了拒绝访问属性"H"的权限.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下代码,以使用Java脚本捕获网页的整个屏幕截图.

I have written the below code to capture the entire screen shot of a webpage using java script.

我正在使用: Firefox版本::49.0.1 Chrome版本::54.0.2840.59 m 硒版本: 3.0.0 操作系统: Win10 64位 Java: 1.8

I'm Using: Firefox Version: 49.0.1 Chrome Version: 54.0.2840.59 m Selenium Version: 3.0.0 OS: Win10 64 bit Java: 1.8

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ScreenCapture {

    public static void main(String[] args) throws IOException {
        System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.flipkart.com/");
        driver.manage().window().maximize();
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
        File capture = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(capture, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg"));
    }
}

网页将向下滚动,但是代码突然停止,并出现以下错误.你能帮忙吗?

The webpage will scroll down but the code stops abruptly with the below error. Could you please help.

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)

推荐答案

只需更新到Firefox Night,它就可以使用.

Just update to Firefox Night and it will work.

可以在> https://www.mozilla .org/zh-CN/firefox/channel/desktop/(标有Beta的那个).

The Firefox Night can be found at https://www.mozilla.org/en-US/firefox/channel/desktop/ (the one labeled Beta).

最好将最新的Webdriver版本与最新的Firefox Night版本一起使用(所有代码和开发工作以及代码问题都集中在该同步上,当然,这样做是有道理的)以更好地涵盖新的最终用户方案.

It's better to use an up-to-date webdriver version with an up-to-date Firefox Night version (all the code and efforts of development and code issues are focused on that synchronization, and of course it makes sense in order to cover newer final users scenarios better).

这篇关于拒绝访问属性"H"的权限.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆