I have been using Mechanize for my basic web page/web app testing. I
am stuck at a place where my page redirects as soon as I login with
the credentials, but i am not able to move to the redirected page.
My code goes some thing like this:
from mechanize import Browser
br= Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(True)
br.set_handle_refresh(True, max_time=1)
br.open(url)
br.select_form(name="login")
br["username"] = "Credential"
br["password"] = "Credential"
resp = br.submit()
print br.title()
Output:
Example Login Redirect
In this case the output for the above code is the title of the
redirect page and not the title of the page after the redirection. My
question might be silly. As i am exploring python for testing a web
page/web app any suggestions is very much appreciated,
Thanks,
Vikram
What do you mean by "title of the redirect page"? Are you redirecting
using javascript?
Anand
On Dec 14, 3:21 pm, Anand Chitipothu <anandol...@gmail.com> wrote:
> 2011/12/14 Vikram Nagesh <charming...@gmail.com>:
Mechanize can't handle javascript redirects as it can't execute
javascript. It can only handle http redirects.
Anand
On Dec 14, 3:54 pm, Anand Chitipothu <anandol...@gmail.com> wrote:
> 2011/12/14 Vikram Nagesh <charming...@gmail.com>:
>
> So what will be the best approach to test this web page/web app,
> (which uses javascript, ajax for custom controls and was done in ruby)
> using python?
Something browser based like Selenim perhaps?
[...]
--
~noufal
http://nibrahim.net.in
Christ was born in 4 B.C.
> Vikram Nagesh <charm...@gmail.com> writes:
>
>> So what will be the best approach to test this web page/web app,
>> (which uses javascript, ajax for custom controls and was done in ruby)
>> using python?
>
> Something browser based like Selenim perhaps?
[...]
I meant Selenium - http://seleniumhq.org/
--
~noufal
http://nibrahim.net.in
Goes (Went) over like a lead balloon.
Selenium is kind of heavy-weight.
If you are comfortable with javascript, you can try
http://www.phantomjs.org/. It is headless browser based on WebKit with
Javascript API. I haven't used it myself, but looks very promising.
Anand