Chrome - org.openqa.selenium.WebDriverException:未知错误:无法在 driver.manage().window().maximize() 处获得自动化扩展; [英] Chrome - org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension at driver.manage().window().maximize();

查看:22
本文介绍了Chrome - org.openqa.selenium.WebDriverException:未知错误:无法在 driver.manage().window().maximize() 处获得自动化扩展;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了 Chrome 浏览器抛出的一种非常不寻常的错误

I am stuck with a very unusual kind of error thrown by Chrome Browser

当我尝试使用以下代码行最大化 chrome 时

When I try to do maximize chrome with below line of code

driver.manage().window().maximize();

我遇到以下错误

org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=57.0.2987.110)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.05 seconds

通过这个示例我做了以下事情

By going through this example I did the below things

1. Updated Chrome driver to latest i.e 2.28 for my Chrome version 
   57.0.2987.110 (64-bit)
2. uninstalled and re-installed Chrome
3. did a project build up in Eclipse even created a new workspace

但没有任何帮助所以我使用了

but nothing helped so I used

    ChromeOptions options = new ChromeOptions();
    options.addArguments("start-maximized");
    driver = new ChromeDriver();

它工作正常,Chrome 驱动程序没有显示错误但是每当我执行一些代码,比如填写表单或点击某个按钮之后,它仍然会在一段时间后抛出上述错误.

it worked and Chrome driver showed no error but whenever I execute some piece of code like filling a form or clicking some button after that it still throws the above error after some time.

推荐答案

总的来说,你看到 WebDriverException: unknown error: cannot get automatic extension 的原因可以有很多.看到此异常的两种最常见情况是:

In general the reason you see WebDriverException: unknown error: cannot get automation extension can be numerous. The two most common cases to see this exception is :

  1. chromedriver 二进制和 Chrome 浏览器 二进制版本不匹配.解决方案:遵循 ChromeDriver Release备注
  2. 使用 driver.manage().window().maximize(); 最大化 Chrome 浏览器.解决方案:使用ChromeOptions.addArguments("start-maximized");最大化Chrome浏览器.
  1. Mismatch between chromedriver binary and Chrome Browser binary versions. Solution : Follow the ChromeDriver Release Notes
  2. Using driver.manage().window().maximize(); to maximize the Chrome Browser. Solution : Use ChromeOptions.addArguments("start-maximized"); to maximize the Chrome Browser.

<小时>

根据您的问题,异常似乎来自上述情况之一.


As per your question the exception seems to be coming from one of the above cases.

尝试以下步骤:

  1. 杀死在 Windows 任务管理器中运行的所有 chromedriver 实例.
  2. 使用 CCleaner 工具清除所有 OS 杂务.
  3. 清理 Eclipse 中的所有项目.
  4. 重新启动系统一次.
  5. 提供以下选项以启动您的 Chrome 浏览器:

  1. Kill all the chromedriver instances running in your windows Task Manager.
  2. Use CCleaner tool to wipe out all the OS chores.
  3. Clean all the projects in Eclipse.
  4. Reboot your system once.
  5. Provide the following options to start your Chrome browser:

ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions"); 
driver = new ChromeDriver(options);

您的程序应该可以使用最新的 chrome 驱动程序 2.28 &Chrome 版本 57.0.2987.110(64 位).如果这对您有帮助,请告诉我.

Your program should work with latest chrome driver 2.28 & Chrome Version 57.0.2987.110 (64-bit). Let me know if this helps you.

这篇关于Chrome - org.openqa.selenium.WebDriverException:未知错误:无法在 driver.manage().window().maximize() 处获得自动化扩展;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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