I am trying to log in to my gmail account using Selenium. However, no matter what I do, Google somehow "knows" that I'm using Selenium. The question is how? I tried to conceal the presence of WebDriver, among other things with no success.
Here's my code:
import time
import random
from fake_useragent import UserAgent
from selenium.common.exceptions import StaleElementReferenceException
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
def init_driver():
ua = UserAgent(verify_ssl=False)
user_agent = ua.random
print(user_agent)
options = webdriver.ChromeOptions()
options.add_argument(f'user-agent={user_agent}')
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
# driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": random_line_no})
print(driver.execute_script("return navigator.userAgent;"))
return driver
driver = init_driver()
driver.get('https://mail.google.com')
driver.find_element('//*[@data-action="sign in"]').click()
username = driver.find_element('//*[@name="identifier"]')
username.send_keys(email_val)
driver.find_element("//*[text()[contains(., Даље')]]").parent.click()
I tried playing with all these additional browser flags and options with no success. How does Google know that I'm using Selenium?