How to remove the chrome is being controlled by automated test software

I just want to remove/hide that Google Chrome banner “the chrome is being controlled by automated test software”

It’s been several years since I’ve done Selenium (and even some time since I used Cypress or Playwright), so I’m a little rusty. Bottom line is you need to use Create Webdriver and add Chrome options. You might need to set useAutomationExtension to False and also "excludeSwitches",["enable-automation"], but disable-infobars might do it (see my example below).

While the following snippet doesn’t focus on exactly what you’re looking for, I found it in a very old Gist I made for myself (private - sorry!) that might get you pointed in the right direction:

Open Chrome Browser to Page
    [Documentation]     Opens _Google Chrome_ to a given web page.
    ...                 For more information on what capabilities that _Google Chrome_
    ...                 supports, see [https://sites.google.com/a/chromium.org/chromedriver/capabilities|this Capabilities & ChromeOptions page].
    ...                 Also, you can see [http://peter.sh/experiments/chromium-command-line-switches|what switches Chrome/Chromium supports] as well.
    [Arguments]         ${URL}
    ${chrm_opts} =  Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    ${prefs}        Create Dictionary   credentials_enable_service=${False}   download.default_directory=${EXECDIR}${/}data_files${/}
    Call Method     ${chrm_opts}   add_experimental_option  prefs   ${prefs}
    # Call Method     ${chrm_opts}   add_argument             test-type  # <-- May be needed for privately-signed certs
    # Call Method     ${chrm_opts}   add_argument             disable-extensions  # <-- Probably deprecated
    Call Method     ${chrm_opts}   add_argument             disable-infobars    # No "this is being remotely controlled", etc.
    # Next line suppresses error: child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain
    Call Method     ${chrm_opts}   add_argument             disable-gpu
    # Call Method     ${chrm_opts}   add_argument             user-agent\=${user_agent}  # Only if you care about User Agent strings
    # Call Method     ${chrm_opts}   add_argument             headless  # If you want to run in headless mode
    Run Keyword If  os.sep == '/'    Create Webdriver    Chrome    crm_alias    chrome_options=${chrm_opts}    executable_path=/usr/lib/chromium-browser/chromedriver
    ...    ELSE    Create Webdriver    Chrome    crm_alias    chrome_options=${chrm_opts}   #service_log_path=${sevargs}
    # Maximize Browser Window  # doesn't work under XVFB
    Set Window Size    1500    800
    # Go To    http://www.useragentstring.com   # <-- Enable this line to verify user agent string
    # Sleep    20 seconds                       # <-- Convenience for the above
    Go To    ${URL}
2 Likes