Skip to content

Instantly share code, notes, and snippets.

@umardx
Created August 8, 2017 15:52
Show Gist options
  • Select an option

  • Save umardx/ac721d812ca61cf7fd96963feec3c8d0 to your computer and use it in GitHub Desktop.

Select an option

Save umardx/ac721d812ca61cf7fd96963feec3c8d0 to your computer and use it in GitHub Desktop.
Auto login bot gmail
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'putYourUsernameHere'
passwordStr = 'putYourPasswordHere'
browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/ServiceLogin?'
'service=mail&continue=https://mail.google'
'.com/mail/#identifier'))
# fill in username and hit the next button
username = browser.find_element_by_id('Email')
username.send_keys(usernameStr)
nextButton = browser.find_element_by_id('next')
nextButton.click()
# wait for transition then continue to fill items
password = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.ID, "Passwd")))
password.send_keys(passwordStr)
signInButton = browser.find_element_by_id('signIn')
signInButton.click()
@sHarshil-Shah

Copy link
Copy Markdown

For new UI it will not work as they changed IDs and all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment