zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    绕过验证码登陆的方法(适合只需登陆一次可以记住登陆台的网站)
    Throughput Controller(吞吐量控制器) 感觉就像个线程控制器来的
    时间戳 和 日期 转换的方法 (含获取当前时间戳的方法)
    pip使用笔记
    可以模拟多种浏览器的网站
    浏览器兼容性说明
    测试套件的使用
    python 时间对比大小 和 间隔多少天
    django数据库操作
    mysql连接工具记录
  • 原文地址:https://www.cnblogs.com/majestyking/p/14728240.html
Copyright © 2011-2022 走看看