I've tried login with Gmail or any Google services but it shows the following "This browser or app may not be secure" message:
I also tried to do options like enable less secure app in my acc but it didn't work. then I made a new google account and it worked with me. but not with my old acc.
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
browser = webdriver.Chrome()
browser.get('https://accounts.google.com/servicelogin')
search_form = browser.find_element_by_id("identifierId")
search_form.send_keys('mygmail')
nextButton = browser.find_elements_by_xpath('//*[@id ="identifierNext"]')
search_form.send_keys('password')
nextButton[0].click()
First of all don't use chrome and chromedriver. You need to use Firefox.(if not installed) Download and install Firefox. Login to Google with normal Firefox.
You need to show the Google site that you are not a robot. You can use code like this:
from selenium import webdriver
import geckodriver_autoinstaller
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
geckodriver_autoinstaller.install()
profile = webdriver.FirefoxProfile(
'/Users/<user name>/Library/Application Support/Firefox/Profiles/xxxxx.default-release')
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
desired = DesiredCapabilities.FIREFOX
driver = webdriver.Firefox(firefox_profile=profile,
desired_capabilities=desired)
This can help you find your profile location.
Actually there is only one reason, chromedriver was coded by Google. They can easily understand if it is a bot or not. But when we add user data with Firefox, they cannot understand if there is a bot or not.
You can fool Google like this. It worked for me too. I tried very hard to do this. Hope it will be resolved in you too.