Testing a website with HTTPS login and cookies

Discussion in 'Python' started by Hari Sekhon, Sep 5, 2006.

  1. Hari Sekhon

    Hari Sekhon Guest

    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
     
    Hari Sekhon, Sep 5, 2006
    #1
    1. Advertising

  2. Hari Sekhon

    Sandra-24 Guest

    Hari Sekhon wrote:
    > 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
     
    Sandra-24, Sep 5, 2006
    #2
    1. Advertising

  3. Hari Sekhon

    John J. Lee Guest

    "Sandra-24" <> writes:

    > Hari Sekhon wrote:
    > > 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.


    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
     
    John J. Lee, Sep 7, 2006
    #3
  4. Hari Sekhon

    John J. Lee Guest

    Hari Sekhon <> writes:

    > 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
     
    John J. Lee, Sep 7, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Randall Parker

    Encryption keys for cookies and https

    Randall Parker, Dec 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    489
    Daniel Fisher\(lennybacon\)
    Dec 7, 2005
  2. rockdale
    Replies:
    5
    Views:
    747
    Chad Scharf
    Jul 5, 2007
  3. _Who
    Replies:
    7
    Views:
    2,783
  4. gian
    Replies:
    15
    Views:
    880
    Tom Anderson
    Aug 1, 2010
  5. jotto
    Replies:
    4
    Views:
    447
    jotto
    Oct 2, 2006
Loading...

Share This Page