[twill] Twill & Form with Javascript

Titus Brown titus at caltech.edu
Thu Jun 8 10:39:19 PDT 2006


On Thu, Jun 08, 2006 at 12:50:45PM -0400, Jaime Mountjoy wrote:
-> Hello.  I am currently using Twill via Python to do some performance testing
-> of a Plone application.  One of the forms that I am working with has a
-> hidden date field which is populated via javascript by an onChange call when
-> three visible fields are changed(year, month, day).  Unfortunately this is a
-> required field.   Do you have any suggestions for dealing with this?  I read
-> in the documentation that Twill does not understand javascript but thought
-> I'd give it one last try.
->  
-> Thanks for your help!

Hi, Jaime,

the only way to do this with twill is to do the calculation yourself --
that is, to write an extension function in Python that mimics the
output of the onChange call.  As a simple example,

-- file 'date_extension.py' --

def fill_date_field(mm, dd, yy):
   date_str = "%s/%s/%s" % (mm, dd, yy)
   twill.commands.fv(1, 'hidden_field', date_str)

--

then in twill,

>> extend_with date_extension
>> fill_date_field 6 7 2006

It's cumbersome, I know ;(.  Let me know if you need any help navigating
the Python datetime module documentation...

cheers,
--titus



More information about the twill mailing list