[twill] unittesting question

Stephen Thorne stephen at netboxblue.com
Fri Aug 11 00:22:59 PDT 2006


On Fri, Aug 11, 2006 at 09:12:31AM +0200, Alex Greif wrote:
> Hi ,
> 
> I just found twill and want to us it to unittest my webapplication.
> But in the language reference I am missing some features which I would
> need. So please tell me whether twill addresses some other needs.
> 
> 1) If calling an url that returns many tables, how can i check the
> content of a specific cell in a specific table?
> 
> 2) if a returned html code contains a specific text field
> (name="name") with the error message "Name missing" behind it, how can
> I check this?
> 
> Or can I use twill only to navigate the site and always have to call
> "show" to get the fullt html code and analyse the contents with
> another framework?

I use py.test and twill together to do testing.

http://shiny.thorne.id.au/shiny/2006/04/twill-and-pytest.html

I go further these days and use beautifulsoup together will twill to do
more interesting testing.

The easiest way of getting the page into bsoup is:

def get_soup():
    from twill.commands import get_browser
    browser = get_browser()
    soup = BeautifulSoup(browser.get_html())
    return soup

For soup usage, see:
http://www.crummy.com/software/BeautifulSoup/documentation.html

-- 
Regards,
Stephen Thorne
Development Engineer

Scanned by the NetBox from NetBox Blue
(http://netboxblue.com/)




More information about the twill mailing list