“This browser or app may not be secure” error while attempting to login in to Gmail account using GeckoDriver Firefox through Selenium and Python

First install undetected-chromedriver using pip. It’s a library which bypass Chrome security and allow you to proceed further.

pip install undetected-chromedriver

Then instead of creating using chromedriver.exe like driver = webdriver.Chrome(r"chromedriver.exe"), use the Chrome() function from the library you just installed.

Full Code Example in Python:

import undetected_chromedriver.v2 as uc
from time import sleep

username="[email protected]"
password ='password'

driver = uc.Chrome()

driver.delete_all_cookies()

driver.get('https://accounts.google.com/ServiceLogin')
sleep(2)

driver.find_element_by_xpath('//input[@type="email"]').send_keys(username)
driver.find_element_by_xpath('//*[@id="identifierNext"]').click()
sleep(2)

driver.find_element_by_xpath('//input[@type="password"]').send_keys(password)
driver.find_element_by_xpath('//*[@id="passwordNext"]').click()
sleep(2)

driver.get('https://gmail.com')
sleep(2)

Leave a Comment