I am trying to test functionality of a web-application using FunkLoad.
The page under testing is just a login form - give email and pwd and if successful it redirects to a index page; if not successful it throws an error.
I have the below code:
self.get(server_url + "/login", description="Get /init/default/login")
params=[['email', '[email protected]'],
['password', 'xxxxx'],
['_formname','login'],
]
ret=self.post('%s/login' % server_url,
params=params,
description="Testing login functionality")
self.logd(self.getBody())
Whether it is a valid email id/pwd or a wrong one, the test throws a 200 as a return code and stays in the same login page.
How do I test posting in forms using FunkLoad?
(BTW, when I tested this web page with a mechanize script, I could login and then routed to the correct index page)
Thank you
Setup the funkload proxy recorder and login into your site using your browser as described in the funkload docs: http://funkload.nuxeo.org/recorder.html
Then you easily check exactly what you are sending via POST. You might be sending other params as you think. In the following example, I am testing a django login that uses the crsfmiddleware, and also has a redirect_to param so the server knows where to redirect to if the login was successful. The test doesn't really use the form, it just sends what the browser would send if someone did. If you want to test real form functionality, the best way is to use something like selenium.
I had to add to extract the crsftoken manually as it changes with every request, and an assert to check that it doesn't return to a login page, but besides that, this test is just like the recorder autogenerated for me:
This works for the following form: