[twill] Help Please - How to use Twill to access Secure

Terry Peppers peppers at gmail.com
Thu Aug 17 14:13:50 PDT 2006

This is actually already built into Twill.

From: http://darcs.idyll.org/~t/projects/twill/doc/commands.html


add_auth <realm> <uri> <user> <password> -- add HTTP Basic
Authentication information for the given realm/URI combination. For

add_auth IdyllStuff http://www.idyll.org/ titus test

tells twill that a request from the authentication realm "IdyllStuff"
under http://www.idyll.org/ should be answered with username 'titus',
password 'test'. If the 'with_default_realm' option is set to True,
ignore 'realm'.


This is how I can do it from the command line:

[terryp at Macintosh] terryp :: python
Python 2.4.3 (#1, Apr  7 2006, 10:54:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from twill.commands import *
>>> u = "http://www.foo.com"
>>> add_auth("Foo Realm", u, "someuser", "somepass")
Added auth info: realm 'Foo Realm' / URI 'http://www.foo.com' / user 'someuser'
>>> go(u)
==> at http://www.yeah.com

The trick in my mind is getting the 'Realm' right - but in the dialog
box that get's thrown it should be mentioned.

Give that a spin.

> Hello Everyone,
> I am a new to Twill.  I have been using Python to automate most of my
> testing tasks in the last 4-5 years.  My current project is to develop a
> tool to login to a local secure website, which use apache to
> authenticate accessing user.  I Google the web and fumble on this
> "Testing Web Apps Effectively with Twill".  After reading the article
> and others related posts, I believe this is the perfect tool for my
> project.  I just want to login to the website, navigate to some selected
> links, fill and submit some forms and retrieve the response for my
> posts.
> I have written a simple script to login a secure website which use a
> "Login" form and it work perfectly.  Until I try to go to the website
> that uses Apache for the authentication step - just popup window and no
> form to fill.  I can use URLILB2 to loggin, but I have not been figure
> out how to gain access to this website using the Twill for its wonderful
> built in feature.

More information about the twill mailing list