Open
Description
Mechanize Browser object is unable to find form on the second page of the login process. Internal data structure of the browser object seems to hold information about the original form.
Here are the chain of events in the multi-stage login process:
- User submits his username / password on the first page (let's call it P1)
- This information is validated by the website and user is redirected to the second page (let's call it P2)
- On P2 user is required to submit answer to the security question.
- However, when user tries to find the form / control for the security answer, Mechanize complains the form /control is not found.
- If response.text is printed for P2 - it displays the HTML of the P2 correctly
Sample code is shown below:
browser = mechanize.Browser(history=None)
browser.open(LOGIN_URL)
browser.select_form(nr = 0)
browser.form['username'] = UID
browser.form['userpass'] = PWD
resp = browser.submit()
security_url = resp.geturl()
print( "The security url is: " + str(security_url) )
resp1 = browser.follow_link(security_url)
forms = list(browser.forms())
for i in range(len(forms)):
print( forms[i].name )
Metadata
Metadata
Assignees
Labels
No labels