Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unable to login with selenium
#1
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
Reply
#2
Look at browser.page_source  to see if you are logged in.
Reply
#3
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
Reply
#4
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)
Reply
#5
ah ok. That time sleep was it.  Big Grin
thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium Parsing (unable to Parse page after loading) oneclick 7 1,645 Oct-30-2020, 08:13 PM
Last Post: tomalex
  Selenium google login probottpric 0 335 Oct-09-2020, 04:19 PM
Last Post: probottpric
  Python-selenium script for automated web-login does not work hectorKJ 2 1,440 Sep-10-2019, 01:29 PM
Last Post: buran
  Unable to access javaScript generated data with selenium and headless FireFox. pjn4 0 907 Aug-04-2019, 11:10 AM
Last Post: pjn4
  locating element with selenium after login sumandas89 1 2,032 Jan-15-2018, 02:40 PM
Last Post: metulburr
  Unable to select iframe using selenium endejoli 1 1,475 Jan-11-2018, 05:13 PM
Last Post: j.crater
  unable to load file using python selenium purnima1 4 4,083 Dec-12-2017, 04:04 PM
Last Post: hshivaraj
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 1,658 Nov-03-2017, 08:41 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020