Permission denied to access property “document”

2019-02-16 00:58发布

问题:

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.

Error Code

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

Java Code

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();

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

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.

回答1:

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 :)