I am trying to test user credentials on a web application that uses POST forms, using the requests library for Python. When my test fails (using the wrong password for a username), I want to capture the error message from the application. Problem is, I can’t find the object’s attribute where this is stored.
Have been using the answer found in HTTP POST and GET with cookies for authentication in python. They mention the replies received from the web application, to confirm if credentials worked or not, but no reference to the attributes.
I used their Python code but cant find the replies in any of the attributes:
>>> r.__dict__.keys()
>>> ['cookies', '_content', 'headers', 'url', 'status_code', '_content_consumed', 'encoding', 'request', 'raw', 'error', 'config', 'history']
Any pointers? Thanks,
Have you tried looking at the documentation for the
requestsmodule? (hint:r.text)(It’s not in
r.__dict__because it is not an attribute of the instance. It’s a property and is therefore stored on the class.dir(r)would have found it, though.)