访问属性“文档”的权限被拒绝 [英] Permission denied to access property "document"

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

问题描述

所以我只是想创建一个能够通过gmail自动化并自动执行某些任务的代码。我设法成功登录到GMail,但是当我尝试检索页面源时登录后我一直遇到此错误代码。

So I'm just trying to create a code that will nagivate through gmail and perform certain tasks automatically. I managed to successfully login into GMail automatically however I keep running into this error code after logging in when I try to retrieve the page source.

错误代码

org.openqa.selenium.WebDriverException: Error: Permission denied to access property "document" (WARNING: The server did not provide any stacktrace information)

Java代码

String pageLink = "https://accounts.google.com/ServiceLogin?service=mail#identifier";

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.get(pageLink);
            WebElement userName = (new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOfElementLocated(By.id("Email")));
            userName.sendKeys("myusername");

            driver.findElement(By.id("next")).click();
            Thread.sleep(2 * 5000);

            WebElement passWord = (new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOfElementLocated(By.id("Passwd")));
            passWord.sendKeys("mypassword");

            driver.findElement(By.id("signIn")).click();
            System.out.println("Logged In!");

            Thread.sleep(2 * 5000);
            pageCode = driver.getPageSource();

注意:我使用的是最新版本的Firefox和最新版本的Selenium

Note: I'm using the latest version of Firefox and latest version of Selenium

PS:关于类似问题,我已经遇到了11个以上的不同问题,没有人提供明确的解决方案,答案非常模糊。

PS: I've been through 11+ different questions regarding the similar issues, no one had provided a clear solution and the answers were extremely vague.

推荐答案

伙计们我很久以前找到了这个问题的解决方案,抱歉忘记发布它,将mozilladriver切换到chromedriver应该可以解决这个问题。干杯:)

Guys I found the solution to this problem ages ago, sorry forgot to post it, switching the mozilladriver to chromedriver should solve this issue. Cheers :)

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

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