解决“chrome正受到自动测试软件的控制”信息栏显示问题-V76及以上版本

在使用Selenium WebDriver启动谷歌浏览器Chrome时,在新启动的浏览器地址栏下方经常会显示一行提示信息:“chrome正受到自动测试软件的控制”,英文的就是“'Chrome is being controlled by automated test software'。

之前我们去掉这个信息栏的做法是传“disable-infobars”参数给chrome driver,但是现在在新版本的chrome浏览器及对应driver中(V76及以上版本),这个参数被废弃掉了,已经无效了。


注:本文的解决方法针对的是V76及以上的谷歌版本及对应driver。

旧版本的解法方法请见https://blog.csdn.net/yoyocat915/article/details/79758000


在新版本的chrome浏览器中我们可以通过下面的方法来禁掉这个信息栏的显示:

ChromeOptions option = new ChromeOptions();		
option.setExperimentalOption("useAutomationExtension", false); 
option.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));		
WebDriver driver = new ChromeDriver(option);

Java完整示例如下:

package com.yoyotesting.selenium3maven;

import java.util.Collections;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class DisableChromeInfobar {

	public static void main(String[] args) {
		System.setProperty("webdriver.chrome.driver", "D:\\browserdriver\\chrome77\\chromedriver.exe");
		
		ChromeOptions option = new ChromeOptions();
		
		//通过ChromeOptions的setExperimentalOption方法,传下面两个参数来禁止掉谷歌受自动化控制的信息栏
		option.setExperimentalOption("useAutomationExtension", false); 
		option.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
		
		WebDriver driver = new ChromeDriver(option);
		
		driver.manage().window().maximize();
		
		driver.get("https://www.baidu.com");
	}

}

 

********************************************************************************************************

近期我会在博客中系统的更新一些关于Selenium的文章,也请大家多多关注下我的视频课程:

入门:基于Java的Selenium3自动化测试完整教程

高级:Selenium Java高级架构课程

*********************************************************************************************************

阅读更多精彩文章,请大家关注我的测试公众号:火烈鸟测试

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YOYO测试

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值