[twill] Converting interactive session to code

Jamal Mazrui Jamal.Mazrui at fcc.gov
Fri Feb 5 09:09:46 PST 2010


I'm trying to automate a Wikipedia search using Google to find the best
matching article.  I have things working in an interactive session with
the twill shell, but for some reason, the code is not finding the Google
search form -- I get the error "twill.errors.TwillAssertionError: no
matching forms!"  

Here is the relevant code:

sQuery = 'Python'
sAddress = 'http://google.com' 
oBrowser = twill.get_browser()
oBrowser.go(sAddress)
twill.commands.formvalue(1, 'q', 'site:wikipedia.org ' + sQuery
twill.commands.submit()
twill.commands.follow('en.wikipedia.org')


Jamal




More information about the twill mailing list