[TIP] twill question

David Brochu brochu121 at gmail.com
Tue Jan 29 06:20:50 PST 2008


> On Fri, Jan 25, 2008 at 11:17:00AM -0800, Brent Pedersen wrote:
> -> > >> I was just wondering, is there was a way to pull a field value
> -> > >> directly from a form? I know you can use showforms() to  
> view all
> -> > >> available forms, but I really need to grab each field name  
> from the
> -> > >> form individually so my Python program can determine what  
> type of
> -> > >> info it should pass to each field.
> ->
> -> hi, i think this is what you want.
> ->
> -> import twill.commands as tc
> -> b = tc.get_browser()
> -> tc.go("http://www.google.com")
> -> forms = tc.showforms()
> -> form = forms.next()
> -> names = [control.name for control in form.controls]
> -> print names
>
> Yep.  Do people wants this to be formalized in an internal API?  Right
> now I don't have much in there for manipulating forms, AFAIK...
>
> cheers,
> --titus


I think its not  a bad idea to include this in an internal API. I  
know I would personally use it a ton!

-dave




More information about the testing-in-python mailing list