Testing a website with HTTPS login and cookies

H

Hari Sekhon

Hi everyone,

I want to create a test that will do a proper login test to a web site
but I need some pointers.

I need to login to the website by accessing an https url and posting to
that, which should return a very small 302 reply with the address of the
internal page. I need to take that page href and then access it, if I
can do all that then the test passes. Of course because I have to access
two urls I also need cookies for session handling. I've already tried
bash which would have worked but for the cookie handling and webinject
which is written in Perl, but this doesn't do exactly what I want in
terms of output so I'd rather write something myself. (I'm also curious
as to the best way to do this)

If anybody knows how to do this could they please give me a quick
pointer and tell me what libraries I need to go read up on?


Thanks

Hari
 
S

Sandra-24

Hari said:
If anybody knows how to do this could they please give me a quick
pointer and tell me what libraries I need to go read up on?

One word. Selenium.

-Sandra
 
J

John J. Lee

Sandra-24 said:
One word. Selenium.

Didn't sound like a good fit for Selenium to me. Selenium's great,
but if you want to test HTTP response codes, just test HTTP response
codes -- no need to drag your browser into it :)


John
 
J

John J. Lee

Hari Sekhon said:
I want to create a test that will do a proper login test to a web site
but I need some pointers.

I need to login to the website by accessing an https url and posting
to that, which should return a very small 302 reply with the address
of the internal page. I need to take that page href and then access
it, if I can do all that then the test passes. Of course because I
have to access two urls I also need cookies for session handling. I've
already tried bash which would have worked but for the cookie handling
and webinject which is written in Perl, but this doesn't do exactly
what I want in terms of output so I'd rather write something
myself. (I'm also curious as to the best way to do this)

If anybody knows how to do this could they please give me a quick
pointer and tell me what libraries I need to go read up on?

You could just use httplib, or urllib2 (using
urllib2.HTTPCookieProcessor) if you need to handle cookies. However,
personally I prefer using a higher-level tool that knows a bit more
about web-browser behaviour, e.g.:

http://www.idyll.org/~t/www-tools/twill.html
http://cheeseshop.python.org/pypi?:action=display&name=ZopeTestbrowser


both of which are based on:

http://wwwsearch.sourceforge.net/mechanize/


(BTW, I hear there's work going on on an implementation of
zope.testbrowser that delegates to Selenium instead of to mechanize --
cool.)


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top