[twill] how to access results from "find"-command

martin martinjanz at gmail.com
Thu Mar 25 01:06:31 PDT 2010


Thanks, but still, how would I print out the results then?
When I try "print b.find("sometext")" it complains AttributeError: 
'TwillBrowser' object has no attribute 'find'.

BTW: Tim Hatch, yours works, thanks

On 25/03/10 00:51, Howard B. Golden wrote:
> Hi martin
>
> On Wednesday March 24, 2010, martin wrote:
>
>    
>> I've been trying to get it working in python, but without any luck:
>>
>> from twill.commands import go, find, echo
>> go("http://somepage")
>> find("sometext")
>>      
> Please see http://twill.idyll.org/python-api.html
>
>  From that page (note the second sentence):
>
> However, the functions in commands.py are too simple for some
> situations. In particular, they do not have any return values, so in
> order to e.g. get the HTML for a particular page, you will need to talk
> to the actual "Web browser" object that twill uses.
>
> To talk to the Web browser directly, call the get_browser function:
>
> from twill import get_browser
> b = get_browser()
>
> b.go("http://www.python.org/")
> b.showforms()
>
> This is the second way to use twill from Python, and it is much more
> flexible. All of the functions in commands.py use this same browser
> object, so you can mix and match:
>
> from twill import get_browser
> b = get_browser()
>
> from twill.commands import *
> go("http://www.python.org/")
> b.showforms()
>
> HTH,
>
> Howard
>
> _______________________________________________
> twill mailing list
> twill at lists.idyll.org
> http://lists.idyll.org/listinfo/twill
>    



More information about the twill mailing list