Created
August 8, 2017 15:52
-
-
Save umardx/ac721d812ca61cf7fd96963feec3c8d0 to your computer and use it in GitHub Desktop.
Auto login bot gmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For new UI it will not work as they changed IDs and all.