I've been having trouble logging in with Selenium web driver as it shows that I can't log in and then test, search for the word pizza, but it doesn't go beyond the login. What I'm interested in is being able to log in.
This is the message that appears to me, Google detects that an external driver is being used
"Couldn’t sign you in This browser or app may not be secure. Learn more Try using a different browser. If you’re already using a supported browser, you can try again to sign in."
The python code I used is this, it was used with selenium 4 and python 3.10.6 (of course I changed the email and password, but still using these or mine, it doesn't go beyond that modal)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
# Start a new instance of the browser
driver = webdriver.Chrome()
# Go to the Google sign-in page
driver.get("https://accounts.google.com/signin")
# Find the username element and fill it with "blabla@gmail.com"
username = driver.find_element(By.NAME, "identifier")
username.send_keys("blabla@gmail.com")
username.send_keys(Keys.RETURN)
# Wait a bit for the page to load
time.sleep(50)
# Find the password element and fill it with "asdf1234" and bang! here it
# denies me doing it with the block because Google classifies me as suspicious.
password = driver.find_element(By.NAME, "password")
password.send_keys("asdf1234")
password.send_keys(Keys.RETURN)
# Wait a bit for the page to load
driver.implicitly_wait(5)
# Go to the Google search page
driver.get("https://www.google.com")
# Find the search element and search for "pizza"!!
search_field = driver.find_element(By.NAME, "q")
search_field.send_keys("pizza")
search_field.send_keys(Keys.RETURN)
Do you have any idea how to solve it?
I've tried different strategies, such as starting in a profile or temporarily duplicating the profile file that Google has in .config/google-chrome/ and using it for this (it generates problems, I don't recommend it) and still can't log in.
Can someone explain to me how I could get it to work?