【问题标题】:Permission denied to access property "document"访问属性“文档”的权限被拒绝
【发布时间】:2016-08-08 03:23:24
【问题描述】:

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

错误代码

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

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

【问题讨论】:

  • Try this answer. 禁用木偶帮助我解决不合逻辑的 WebDriverException。

标签: java selenium selenium-webdriver automation


【解决方案1】:

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

【讨论】:

  • 我发现它以不同的方式随机失败。只有java。 python 中的 Firefox 驱动程序在当前版本下运行良好。
  • 它也主要是在使用 maven junit 穿过黄瓜时失败。
  • 这并不能真正解决问题...我有同样的问题,但我必须使用 mozilla 驱动程序...无论如何感谢分享
猜你喜欢
  • 2014-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多