Python Forum

Full Version: unable to login with selenium
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
im trying to use selenium to login to a site. However when i attempt to login, i dont think i am logging in as the browser.title still retains "Sign In" when if it is logged in should be "Dashboard"

from selenium import webdriver
import time
import os

# 'https://chromedriver.storage.googleapis.com/index.html?path=2.25/'
chromedriver = "/home/metulburr/Downloads/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
browser = webdriver.Chrome(chromedriver)
browser.get("https://dg.coupons.com/signin/") 
time.sleep(10) 
username = browser.find_element_by_id("email")
password = browser.find_element_by_id("password")
username.send_keys("USER_EMAIL")
password.send_keys("USER_PASSWORD")
login_attempt = browser.find_element_by_xpath("//*[@type='submit']")
login_attempt.submit()

print(browser.title)
Output:
$ python test1.py Sign In
Look at browser.page_source  to see if you are logged in.
it doesnt appear to me to be logged in. 

codepad:
http://codepad.org/Wse8xDuY

codepad it  due to other reasons:
http://python-forum.io/Thread-html-in-co...ighlighter
Set sleep before page_source so you are sure it have load in.
Then find something in source that are there only when logged in and compare.
time.sleep(6)
print(browser.page_source)
ah ok. That time sleep was it.  Big Grin
thanks.