Skip to content

Instantly share code, notes, and snippets.

@aaronmyatt
Forked from ikegami-yukino/google_login.py
Last active October 27, 2017 08:20
Show Gist options
  • Save aaronmyatt/cc9baac256e156164a8180195c198668 to your computer and use it in GitHub Desktop.
Save aaronmyatt/cc9baac256e156164a8180195c198668 to your computer and use it in GitHub Desktop.
Automatically Google login by selenium
mail_address = ''
password = ''
from selenium import webdriver
UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0'
PHANTOMJS_ARG = {'phantomjs.page.settings.userAgent': UA}
driver = webdriver.PhantomJS(desired_capabilities=PHANTOMJS_ARG)
url = 'https://www.google.com/accounts/Login?hl=ja&continue=http://www.google.co.jp/'
driver.get(url)
# OLD
# driver.find_element_by_id("Email").send_keys(mail_address)
# driver.find_element_by_id("next").click()
# driver.find_element_by_id("Passwd").send_keys(password)
# driver.find_element_by_id("signIn").click()
# NEW
driver.find_element_by_id("identifierId").send_keys(mail_address)
driver.find_element_by_id("identifierNext").click()
driver.find_element_by_name("password").send_keys(password)
driver.find_element_by_id("passwordNext").click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment