[twill] Form field values?

Brett Carter brett at kavi.com
Tue Feb 7 17:01:12 PST 2006

I added a simple method, 'getvalue' to commands.py that gets the current
value of a field and sets it in a named local variable.  Interested in a

def getvalue(formname, fieldname, localval):
    >> getvalue <formname> <field> <local_var>

    gets a value of a given field on a form and sets it in a
    local variable


titus at caltech.edu wrote:
> On Tue, Feb 07, 2006 at 03:43:36PM -0800, Brett Carter wrote:
> -> Is there any way to grab values from named form fields using twill other
> -> than using 'find'?  Like I just want to grab the value of the hidden
> -> field named 'selected_key' and store it in a variable.
> -> -Brett
> Hi, Brett,
> I don't have any specific API for it, no.  If you're willing to use
> Python directly, then something along the lines of
> 	b = twill.get_browser()
> 	form = twill.get_form(formname)
> 	field = browser.get_form_field(form, fieldname)
> 	value = field.value
> should work.
> --titus

More information about the twill mailing list