Last active
October 7, 2015 02:06
-
-
Save sqe/86932edeb05f365364f2 to your computer and use it in GitHub Desktop.
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.keys import Keys | |
from selenium.webdriver.support.ui import WebDriverWait | |
def login(): | |
browser = webdriver.Firefox() | |
browser.get('https://instagram.com/accounts/login') | |
''' | |
When page loads the Login Form Container is not loaded immediately, that is why we need to do a smart wait, | |
the following waits up to 15 seconds if the element not found immediately. | |
''' | |
wait = WebDriverWait(browser, 15) | |
wait.until(lambda browser: browser.find_element_by_css_selector('.-cx-PRIVATE-Login__formContainer')) | |
username_field = browser.find_element_by_name("username").send_keys("username") | |
password_field = browser.find_element_by_name("password").send_keys("password") | |
login_button = browser.find_element_by_css_selector('.-cx-PRIVATE-LoginForm__loginButton') | |
login_button.click() | |
browser.quit() | |
login() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment