谷歌浏览器正受到自动测试软件的控制闪退,解决“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:

2675b122189c

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值