SOURCE CODE
First of all you need to install the below library
using the pip
command as shown below
pip install selenium
Now you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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') |
As you can see we are automatically opening the browser
tab and going to the gmail
login page and automatically filling out the username
and password
and clicking the submit
button to login as shown below