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

  • 相关阅读:
    ACM进阶
    hdu 2018 母牛的故事
    hdu 2084 数塔
    动态规划算法
    hdu 1003 Max sum
    hihocoder 1037 数字三角形
    UDP和TCP的区别(转)
    JS简单的图片左右滚动
    C# MD5加密的方法+一般处理程序使用Session+后台Json序列化
    CSS DIV 独占一行,清除左右两边的浮动
  • 原文地址:https://www.cnblogs.com/majestyking/p/14728240.html
Copyright © 2011-2022 走看看