• Selenium去掉Chrome is being controlled by automated test software.


    在selenium打开google chrome浏览器时,会出现以下inforbar,老显示:

    Chrome is being controlledby automated test software.

    为了去掉这个烦人的inforbar,需要在启动浏览器,新建Chrome Driver实例时加入以下参数.

    一句话,三行代码搞定:

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

    或者这样:

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

    或者这样:

    ChromeOptions options = new ChromeOptions();
     options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
    driver = new ChromeDriver(options);

    以下时以前的旧方法,现在已经不起作用了.

    ChromeOptions option = new ChromeOptions();
    option.AddArguments("disable-infobars");
    driver = new ChromeDriver(option);

    设置Google Chrome,主要用到的Google Chrome的ChromeOption和Selenium的 Capabiliti.

    这篇参考文章很详细:

    https://www.codota.com/code/java/methods/org.openqa.selenium.chrome.ChromeOptions/setExperimentalOption

    参考资料:

    https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification
    https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md#--enable-automation

    https://www.seleniumeasy.com/selenium-tutorials/using-chrome-options-for-webdriver-tests#:~:text=Chrome%20Options%20for%20running%20WebDriver%20Tests%201%20Chrome,4%20Headless%20Chrome.%20...%205%20Load%20Extensions.%20

    https://www.seleniumeasy.com/selenium-tutorials/using-chrome-options-for-webdriver-tests#:~:text=Chrome%20Options%20for%20running%20WebDriver%20Tests%201%20Chrome,4%20Headless%20Chrome.%20...%205%20Load%20Extensions.%20

    Google官网介绍

    https://sites.google.com/a/chromium.org/chromedriver/capabilities

    https://chromedriver.chromium.org/capabilities

    List of Chromium Command Line Switches

    https://peter.sh/experiments/chromium-command-line-switches/

    以下文章页有用

    https://www.edureka.co/community/145/notification-controlled-automated-software-chromedriver

    https://zhuanlan.zhihu.com/p/89451454

    https://www.edureka.co/community/11236/setting-up-chromeoptions-and-setexperimentaloption-code

  • 相关阅读:
    CSP2019滚粗记
    [总结] wqs二分学习笔记
    [总结] 圆方树学习笔记
    [CF960G] Bandit Blues
    [总结] 第一类斯特林数
    [EOJ629] 两开花
    [CF286E] Ladies' shop
    [总结] 动态DP学习笔记
    [BZOJ3879] SvT
    [总结] 替罪羊树学习笔记
  • 原文地址:https://www.cnblogs.com/majestyking/p/14728240.html
Copyright © 2020-2023  润新知