How to get rid of the infobar "Chrome is being controlled by automated test software" through Selenium
Asked Answered
T

5

12

Been searching for a while and tried all the solutions present but none appear to be working. I created a "slide show" that will first log in, then alternate between tabs. All of that is working but i cannot get rid of the

"Chrome is being controlled by automated test software" bar. Any advise?

Code

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'test'
passwordStr = 'test'
browser = webdriver.Chrome()

#first tab
browser.get(('www.testwebsite.com?'))
# fill in username and hit the next button
username = browser.find_element_by_id('username')
username.send_keys(usernameStr)
password = WebDriverWait(browser, 10).until(
    EC.presence_of_element_located((By.ID, 'password')))
password.send_keys(passwordStr)
nextButton = browser.find_element_by_class_name('emp-submit')
nextButton.click()

#second tab
browser.execute_script("window.open('about:blank', 'tab2');")
browser.switch_to.window("tab2")
browser.get('www.testwebsite.com')
Teshatesla answered 2/10, 2018 at 18:49 Comment(3)
Possible duplicate of Chrome is being controlled by automated test softwareContestant
Possible duplicate of #43410416Prokopyevsk
Same question but for C#: c# - Unable to hide "Chrome is being controlled by automated software" infobar within Chrome v76 - Stack OverflowCholla
J
5

When you open Chrome Browser in through ChromeDriver this infobar containing the notification is embedded as follows:

Chrome is being controlled by automated test software
  • Browser snapshot without the argument disable-infobars:

infobar

But if you add the argument disable-infobars through an instance of ChromeOptions you can get rid of this infobar as follows:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.add_argument('start-maximized')
    options.add_argument('disable-infobars')
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get('https://www.google.com/')
    
  • Browser snapshot applying the argument disable-infobars:

no_infobar

Judaea answered 2/10, 2018 at 19:14 Comment(2)
This does not work anymore for the latest chromedriversKingery
Same as above. Does not work, using: Version 87, windows10.Sail
L
22

Try this:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_experimental_option("useAutomationExtension", False)
options.add_experimental_option("excludeSwitches",["enable-automation"])

driver_path = '/Users/myuser/Downloads/chromedriver'
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)
driver.get('https://google.com')

driver.close()
Luciusluck answered 10/12, 2020 at 18:17 Comment(4)
The only one that still works great (Chromedriver for Windows, version 89).Bipropellant
options.add_experimental_option("useAutomationExtension", False) options.add_experimental_option("excludeSwitches",["enable-automation"]) works and it is the part responsible for the test banner right..... Thank you.Injun
Works beautifully on Ubuntu as well as Windows!Wollis
chrome_options should be options now, and executable_path should be inside Service: #76551006Cholla
J
5

When you open Chrome Browser in through ChromeDriver this infobar containing the notification is embedded as follows:

Chrome is being controlled by automated test software
  • Browser snapshot without the argument disable-infobars:

infobar

But if you add the argument disable-infobars through an instance of ChromeOptions you can get rid of this infobar as follows:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.add_argument('start-maximized')
    options.add_argument('disable-infobars')
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get('https://www.google.com/')
    
  • Browser snapshot applying the argument disable-infobars:

no_infobar

Judaea answered 2/10, 2018 at 19:14 Comment(2)
This does not work anymore for the latest chromedriversKingery
Same as above. Does not work, using: Version 87, windows10.Sail
M
3

Your Chrome browser is detecting the Selenium automation process. To get around this, you could use a different driver that is not detected by Chrome. I've included an example below using the undetected_chromedriver module.

Install undetected_chromedriver module # pip install undetected_chromedriver

#pip install undetected_chromedriver
import undetected_chromedriver as UC

And replace it here

from selenium import webdriver

Now make a driver variable

driver = UC.Chrome()

When you run this code you will see a chromedriver is generated in the same directory where you work.

It work same thing that this line of code do

path = "chromdriver\\chromedriver.exe"
driver = webdriver.Chrome(path)

Here is an Example:

import undetected_chromedriver as UC
driver = UC.Chrome()
driver.get("https:\\www.gmail.com")
driver.find_element_by_xpath('//*[@id ="identifierId"]').send_keys("Your Email Address")
driver.find_element_by_xpath('//*[@id ="identifierNext"]').click()
driver.find_element_by_xpath('//*[@id ="password"]/div[1]/div / div[1]/input').send_keys("Your Password")
driver.find_element_by_xpath('//*[@id ="passwordNext"]').click()
print("Login Successfull...!!")
Mannerheim answered 5/3, 2023 at 10:20 Comment(0)
M
1

THIS IS WORKING WITH LATEST RELEASE. Try it by changing driver path under "service_obj"

from selenium import webdriver

from selenium.webdriver.chrome.service import Service

chrome_options = webdriver.ChromeOptions()

chrome_options.add_experimental_option("useAutomationExtension", False)

chrome_options.add_experimental_option("excludeSwitches",["enable-automation"])

service_obj = Service(r"C:\Users\Documents\Sublime_srk\drivers\chromedriver_win32\chromedriver.exe")

driver = webdriver.Chrome(options=chrome_options,service=service_obj)

driver.get("https://www.google.co.in/")
Masochism answered 24/7, 2022 at 18:5 Comment(1)
Your answers could be improved by adding an explanation of the code you supplied.Archpriest
S
0

Click on the "x" to close the bar. It doesn't work initially, but then maximize and restore the window and it should disappear. This is for anyone who doesn't trigger their tests through Java.

Semibreve answered 4/10, 2021 at 8:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.