[twill] how to not follow redirects

Titus Brown titus at caltech.edu
Thu Jun 21 06:21:20 PDT 2007

On Wed, Jun 20, 2007 at 04:33:54PM -0700, Kevin Turner wrote:
-> Hi,
-> I want to test the content of a Location response-header issued by the
-> server (in the case of a 302 redirect) without actually following the
-> redirect.  This is very hard to do in twill-0.9b1.
-> The first obstacle is that I found no option in twill to disable the
-> automatic redirect handling.
-> That can be overcome by digging in to mechanize a bit and doing
-> twill.commands.get_browser()._browser.set_handle_redirect(False).  Then
-> when twill receives a redirect, you can test to make sure it's a
-> redirect with twill.commands.code(302).
-> However, twill's ResponseWrapper doesn't make any of the headers
-> accessible, so I then had to pull them out of
-> get_browser()._browser.response().info().
-> Would it be okay to make public interfaces to these things?

Hi Kevin!  Yes, both are easy to do and they're both good suggestions;
I'll implement them.

Incidentally, not sure how many on this list read my blog, but I've just
co-authored an e-book, _Intro to Web Testing with twill and Selenium_.


It's probably the most complete introduction to twill available; if
anyone buys it, please let me know what you think.


More information about the twill mailing list