ChromeDriver - Disable developer mode extensions p

2019-01-06 19:48发布

I'm having the following issue: When I'm running my automation tests, I keep getting the following alert "Disable Developer Mode Extension" in Chrome.

enter image description here

Is there a way to remove/disable this?. It is a blocker for me as it is making me fail some tests.

Thanks in advance

11条回答
爷、活的狠高调
2楼-- · 2019-01-06 20:14

resolved in chrome 54 and chromedriver 2.25

查看更多
Luminary・发光体
3楼-- · 2019-01-06 20:16

This is because one of your extensions is running in developer mode. Go through your extension list and disable extensions one-by-one until you find the culprit(s).

查看更多
我只想做你的唯一
4楼-- · 2019-01-06 20:17

I cannot disable extensions because I'm developing & testing one.

What I'm doing to dismiss this popup is the following:

  1. I load chrome with my extension using Selenium.
  2. I then immediately create a new window (via the SendKeys(Control-N) method). This predictably brings up the "Disable Developer Mode Extensions" popup after 3 seconds in the new window.
  3. I can't tell programmatically when it pops up (doesn't show in screenshots) so instead I simply wait 4 seconds.
  4. Then I close the tab via driver.Close(); (which also closes this new window). Chrome takes that as "cancel", dismissing the popup, leaving the original window and tab.

I find this necessary because the popup interferes with normal selenium browser interaction, like SendKeys, which I'm using to switch tabs and windows.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-01-06 20:20

Try to add setProperty above ChromeDriver instance

System.setProperty("webdriver.chrome.driver","C:/[PATH]/chromedriver.exe");
driver = new ChromeDriver(capabilities);
查看更多
我只想做你的唯一
6楼-- · 2019-01-06 20:21

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

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

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.

查看更多
登录 后发表回答