Created
March 13, 2017 18:36
-
-
Save leppie/13f943e90dc546d7216df694e9b221d5 to your computer and use it in GitHub Desktop.
Google login via PhantomJS
This file contains 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
mail_address = '' | |
password = '' | |
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 | |
UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36' | |
PHANTOMJS_ARG = {'phantomjs.page.settings.userAgent': UA} | |
driver = webdriver.PhantomJS(desired_capabilities=PHANTOMJS_ARG) | |
url = 'https://www.google.com/accounts/Login?hl=en&continue=http://www.google.com/' | |
driver.get(url) | |
driver.find_element_by_id("Email").send_keys(mail_address) | |
driver.find_element_by_id("next").click() | |
wait = WebDriverWait(driver, 10) | |
e = wait.until(EC.visibility_of_element_located((By.ID, 'Passwd'))) | |
e.send_keys(password) | |
driver.find_element_by_id("signIn").click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment