[TIP] twill question

David Brochu brochu121 at gmail.com
Fri Jan 25 11:01:20 PST 2008

Thanks for the help Terry.

Unfortunately the code you supplied only returns the values passed to  
the form fields, not the name of the form fields themselves. In your  
example what I would like to have returned is the form field "q", not  
the contents of q.

On Jan 25, 2008, at 12:26 PM, Terry Peppers wrote:

> Hi David.
>> I've been using Twill quite extensively for the past month or so and
>> I love it.
> Same here.
>> 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.
> This probably isn't the most elegant way, but it's a way.
> ---- START SNIP -----
>>>> from twill.commands import *
>>>> go("http://www.google.com")
> ==> at http://www.google.com
> 'http://www.google.com'
>>>> fv(1, "q", "python and twill")
>>>> f = get_browser().get_form("f")
>>>> f.get_value("q")
> 'python and twill'
> ---- END SNIP -----
> From my understanding of Twill, you have to call the get_browser() and
> get_form() methods. By passing the name of the form to the get_form()
> method, you then should be able to use the get_value() method if you
> pass it the name of the form field.
> I swear there's a better way. Maybe Titus can answer better.
> t.
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list