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();
问题描述
我遇到了 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 :
chromedriver
二进制和Chrome 浏览器
二进制版本不匹配.解决方案:遵循ChromeDriver Release备注
- 使用
driver.manage().window().maximize();
最大化Chrome 浏览器
.解决方案:使用ChromeOptions.addArguments("start-maximized");
最大化Chrome浏览器
.莉>
- Mismatch between
chromedriver
binary andChrome Browser
binary versions. Solution : Follow theChromeDriver Release Notes
- Using
driver.manage().window().maximize();
to maximize theChrome Browser
. Solution : UseChromeOptions.addArguments("start-maximized");
to maximize theChrome Browser
.
<小时>
根据您的问题,异常似乎来自上述情况之一.
As per your question the exception seems to be coming from one of the above cases.
尝试以下步骤:
- 杀死在 Windows 任务管理器中运行的所有
chromedriver
实例. - 使用
CCleaner
工具清除所有OS
杂务. - 清理 Eclipse 中的所有项目.
- 重新启动系统一次.
提供以下选项以启动您的 Chrome 浏览器:
- Kill all the
chromedriver
instances running in your windows Task Manager. - Use
CCleaner
tool to wipe out all theOS
chores. - Clean all the projects in Eclipse.
- Reboot your system once.
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屋!