Python Forum

Full Version: How do I get rid of "Chrome is being controlled by automated test software"?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I'm a new member here.

I've made a code here with a tool that most of you are probably familiar with; Selenium.
The code itself is working fine, but my issue is that I cannot get past the
"Chrome is being controlled by automated test software"-lock in Chrome.

I cannot be logged in to Google and/or Youtube due to "security reasons", because of the Selenium tool.
I have looked up other forums and saw some codes were given to get around this issue,
but they were not helpful and didn't do the job for me at all.
All I want is to remain logged in to Google and Youtube as I'm executing the code.

Any help? Thank you in advance.

Also, I'm new to programming, so please make it easy for me.

from selenium import webdriver
import time

chrome_driver = webdriver.Chrome('D:\PycharmProjects\Refresher\chromedriver.exe')
no_of_driver = int(input("Enter number of drivers: "))
url = input("Enter URL: ")
time_to_refresh = int(input("Enter refresh rate in seconds: "))
drivers = []

for i in range(no_of_driver):
    drivers.append(webdriver.Chrome(executable_path="D:\PycharmProjects\Refresher\chromedriver.exe"))
    drivers[i].get(url)
while True:
    time.sleep(time_to_refresh)
    for i in range (no_of_driver):
        drivers[i].refresh()
Add in options.
options.add_experimental_option("excludeSwitches", ['enable-automation']) 
Do not use single \ in path becuse of escape character,can add r.
Chrome(r'D:\PycharmProjects\Refresher\chromedriver.exe')
Example.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ['enable-automation'])
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get("http://www.google.com")
time.sleep(2)
accept_button = browser.find_elements_by_css_selector('#L2AGLb')[0]
accept_button.click()
time.sleep(2)
search_bar = browser.find_elements_by_css_selector('div.a4bIc > input')[0]
search_bar.send_keys('2022')
search_bar.submit() 
(Feb-23-2022, 07:36 AM)snippsat Wrote: [ -> ]Add in options.
options.add_experimental_option("excludeSwitches", ['enable-automation']) 
Do not use single \ in path becuse of escape character,can add r.
Chrome(r'D:\PycharmProjects\Refresher\chromedriver.exe')
Example.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ['enable-automation'])
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get("http://www.google.com")
time.sleep(2)
accept_button = browser.find_elements_by_css_selector('#L2AGLb')[0]
accept_button.click()
time.sleep(2)  

search_bar = browser.find_elements_by_css_selector('div.a4bIc > input')[0]
search_bar.send_keys('2022')
search_bar.submit() 
I'm trying this right now, based on something I saw in another discussion on this group, but don't know the syntax for that last line. It doesn't like just "row" in the append. The fetchall is returning a tuple.