【发布时间】: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