elc*_*rua 34 java selenium selenium-chromedriver selenium-webdriver
我遇到了以下问题:当我运行自动化测试时,我在Chrome中不断收到以下警告"禁用开发人员模式扩展".
有没有办法删除/禁用此功能?这对我来说是一个阻碍因为它让我失败了一些测试.
提前致谢
小智 55
您是否尝试使用命令行参数禁用开发人员扩展?
尝试使用以下Selenium WebDriver java代码:
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);
Run Code Online (Sandbox Code Playgroud)
我无法禁用扩展,因为我正在开发和测试扩展.
我正在做的解雇这个弹出窗口的内容如下:
SendKeys(Control-N)
方法).这可预测地在新窗口中显示 3秒后的"禁用开发者模式扩展"弹出窗口.driver.Close();
(这也关闭了这个新窗口).Chrome将其视为"取消",取消弹出窗口,保留原始窗口和标签.我发现这是必要的,因为弹出窗口干扰了正常的selenium浏览器交互,比如SendKeys,我用它来切换标签和窗口.
As of Chromedriver v2.33, the correct way to avoid this message is to pass load-extension
to the excludeSwitches
argument of the chromeOptions
object. The following Java code should do the trick, although I haven't tested it, as I am running Python:
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", Collections.singletonList("load-extension"));
Run Code Online (Sandbox Code Playgroud)
As others have pointed out, the culprit is probably the Chrome Automation Extension, which is loaded automatically by Chromedriver when it launches Chrome.
Chromedriver v2.33 introduced the new switch to prevent the extensions from being loaded:
Updates to excludeSwitches capability that now allows to exclude --load-extension switch.
I suspect that this solution does not require you to disable all extensions. You should still be able to manually load others.
归档时间: |
|
查看次数: |
42635 次 |
最近记录: |