forms - Staying logged in with Selenium in Python -
i trying log website , once logged in navigate different page on website remaining logged in, using selenium. however, when try navigate different page, found have become logged off.
i believe because not understand how webdriver.firefox().get()
function works exactly.
my code:
from selenium import webdriver code.other import xmlparser #initialise driver , go webpage driver = webdriver.firefox() url = 'http://www.website.com' driver.get(url) #login username = xmlparser.xmlparse('./config.xml','username') password = xmlparser.xmlparse('./config.xml','password') element = driver.find_elements_by_id('username') element[0].send_keys(username) element = driver.find_elements_by_id('password') element[0].send_keys(password) element = driver.find_elements_by_id('submit') element[0].click() #go new page url = 'http://www.website.com/page1' driver.get(url)
unfortunately navigated new page no longer logged in. how fix this?
looks website doesn't have enough time react on submit in authorization form. click submit
don't wait response , open url.
wait until event after login (like getting cookies or changes in dom or time.sleep
) , go page.
p.s.: if won't help, try check cookies after login , after open new url, maybe it's problem authorization backend or webdriver
Comments
Post a Comment