解决“chrome正受到自动测试软件的控制”信息栏显示,使用disable-infobars属性不生效问题

        今天突然有同时问 selenium 怎么去掉浏览器默认的 “chrome正受到自动测试软件的控制”信息栏显示问,说是百度好多文章都说是通过设置disable-infobars属性可以解决,尝试后都不行,最后去谷歌找了下发现是新版本中该属性已经被废弃导致的,具体如下:

Recent versions of Chrome display notification bar at the top of the browser saying "Chrome is being controlled by automated test software", as follows:


Previously, passing the "disable-infobars” ChromeOption to the WebDriver prevented Chrome from displaying this notification. Recently, the "disable-infobars" option has been deprecated and no longer removes the notification. The current workaround for this is to pass in an option called "excludeSwitches" and then exclude the "enable_automation" switch.

java 或python的解决方法:

java:

```

ChromeOptions options = new ChromeOptions();

options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});

WebDriver driver = new ChromeDriver(options);

```

python3

```

chrome_options = webdriver.ChromeOptions();

chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);

driver = webdriver.Chrome(options=chrome_options);

```

参考原文:

https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容