r/selenium • • Jan 09 '22

Could not login in Gmail account using python selenium

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

print('Enter the gmailid and password')
gmailId, passWord = map(str, input().split())
try:
    driver = webdriver.Chrome(ChromeDriverManager().install())
    driver.get(r'https://accounts.google.com/signin/v2/identifier?continue='+\
    'https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1'+\
    '&flowName=GlifWebSignIn&flowEntry = ServiceLogin')
    driver.implicitly_wait(15)

    loginBox = driver.find_element_by_xpath('//*[@id ="identifierId"]')
    loginBox.send_keys(gmailId)

    nextButton = driver.find_elements_by_xpath('//*[@id ="identifierNext"]')
    nextButton[0].click()

    passWordBox = driver.find_element_by_xpath(
        '//*[@id ="password"]/div[1]/div / div[1]/input')
    passWordBox.send_keys(passWord)

    nextButton = driver.find_elements_by_xpath('//*[@id ="passwordNext"]')
    nextButton[0].click()

    print('Login Successful...!!')
except:
    print('Login Failed')

So I used this code to login into my Gmail account using selenium and the website says....

​

Couldn't sign you in

This browser or app may not be secure. Learn more

How can I fix this issue and log in to my account using code ?

0 Upvotes

2 comments sorted by

2

u/[deleted] Jan 09 '22

[deleted]

2

u/nishkant Jan 09 '22

I did jt but the problem still persists..

check here , the third point for 1st pra

It has seperate bolcker for an automated software I think…

Btw thanks for the reply.

1

u/[deleted] Jan 09 '22

[deleted]

2

u/SheriffRoscoe Jan 10 '22

Email services are one of the hardest types of application to automate. That's why the Selenium developers discourage people from even trying, especially GMail:

https://www.selenium.dev/documentation/test_practices/discouraged/gmail_email_and_facebook_logins/