Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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')
like image 760
sic_null Avatar asked Oct 02 '18 18:10

sic_null


People also ask

How to disable the “disable-Infobars” chrome option in chromedriver?

Passing the "disable-infobars” ChromeOption to the WebDriver, prevents Chrome from displaying this notification. Here is the relevant syntax to do so: ChromeOptions options = new ChromeOptions (); options.addArguments ("disable-infobars"); WebDriver driver = new ChromeDriver (options); Disable chrome save password dialog using selenium.

How to disable Infobars notification on Chrome?

From V2.28 chrome driver add this information bar, from which we should able to known our automation script running on the chrome. Passing the "disable-infobars” ChromeOption to the WebDriver, prevents Chrome from displaying this notification. Here is the relevant syntax to do so: ChromeOptions options = new ChromeOptions ();

How to disable Chrome browser updates when chrome driver initiates selenium test?

Is there a way to disable chrome browser updates when chrome driver initiates a selenium test. In other words, firefox has an option like this : firefoxProfile.setPreference ("app.update.auto", false); This will make sure the firefox browser doesnot get updated when running the tests.

Is there a way to remove the InfoBar flag in PERF testing?

This flag is no longer needed by the perf testing infrastructure and can be misused for malicious purposes, so remove it. So either you can downgrade your chrome version or start ignoring the infobar in the new version. Show activity on this post. Show activity on this post. Show activity on this post.


2 Answers

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()
like image 85
Ajay Pandey Avatar answered Sep 19 '22 00:09

Ajay Pandey


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

like image 21
undetected Selenium Avatar answered Sep 22 '22 00:09

undetected Selenium