Jeff Forcier wrote:
I'm pretty sure my problem is also b); if I do not use twill to try
and manipulate the dropdowns (they have default values) then twill
itself works fine. Once the data passes through twill, yes, what
should be three values becomes just one value, in this case the
selected value of the last/third dropdown.

See attached patch. I have two things in there, one is for specifying a fieldnum, the other is for being able to specify the name of the form for submitting, which is useful in the following case:
<form><input type='submit' name='foo'></form>
<form><input type='submit' name='bar'></form>

you can do:

submit 'bar' 2

to submit the 'bar' button on the second form, this is otherwise impossible because you can only select the second form by modifying a field.

the fieldvalue call has been changed to do this:

fieldvalue myform myfield myvalue 2

to change the 2nd field of that name.

So yea, if you have that patch handy, I definitely wouldn't mind
taking a peek at it to see if it looks like it'd address my particular
issue. I haven't yet used darcs; when you say "the tests" I assume you
mean twill's own tests?

Yeah, I mean twills own tests. You can add the webpage to twill/tests/twilltestserver.py and either do something in the style of test-checkbox.py (that's my style of using twill) or call twilltestlib.execute_twill_script('test-form.twill', initial_url=url) like test-form.py, and add a .twill file.

:)
--
Regards,
Stephen Thorne
Development Engineer

Scanned by the NetBox from NetBox Blue
(http://netboxblue.com/)




New patches:

[allow a second arg to 'submit' to allow specifying a formname or number.
Stephen Thorne <[EMAIL PROTECTED]>**20060406050052] {
hunk ./twill/browser.py 400
-    def submit(self, fieldname):
+    def submit(self, fieldname, formname=None):
hunk ./twill/browser.py 414
-            else:
-                raise Exception("more than one form; you must select one (use 'fv') before submitting")
+
+        if not form:
+            try:
+                form = forms[int(formname)-1]
+            except (TypeError, ValueError):
+                pass
+
+        if not form:
+            for f in forms:
+                if f.name == formname:
+                    form = f
+                    break
+
+        if not form:
+            raise Exception("more than one form; you must select one (use 'fv') before submitting")
hunk ./twill/commands.py 321
-def submit(submit_button=None):
+def submit(submit_button=None, formname=None):
hunk ./twill/commands.py 337
-    browser.submit(submit_button)
+    browser.submit(submit_button, formname)
}

[Add a new arg to 'formvalue', fieldnum=N, where N is the Nth (1 indexed) field in the form.
Stephen Thorne <[EMAIL PROTECTED]>**20060418230206] {
hunk ./twill/browser.py 378
+
+    def get_form_fields(self, form, fieldname):
+        """
+        Return all the controls that match 'fieldname', which is either a
+        string, or a regexp.
+        """
+        
+        all_found = [ c for c in form.controls if str(c.name) == fieldname ]
+        if all_found:
+            return all_found
+
+        regexp = re.compile(fieldname)
+        all_found = [ ctl for ctl in form.controls if regexp.search(str(ctl.name)) ]
+        if all_found:
+            return all_found
+
+        # try value, for readonly controls like submit keys
+        all_found = [ c for c in form.controls 
+                         if c.value == fieldname and c.readonly ]
+
+        return all_found
hunk ./twill/commands.py 379
-def formvalue(formname, fieldname, value):
+def formvalue(formname, fieldname, value, fieldnum=-1):
hunk ./twill/commands.py 405
-    form = browser.get_form(formname)
+    form = browser.get_form(str(formname))
hunk ./twill/commands.py 409
-    control = browser.get_form_field(form, fieldname)
+    if fieldnum == -1:
+        control = browser.get_form_field(form, fieldname)
+    else:
+        controls = browser.get_form_fields(form, fieldname)
+        control = controls[int(fieldnum)-1]
}

Context:

[added never-fail option, set_errout option
[EMAIL PROTECTED] 
[bumped version number to a3
[EMAIL PROTECTED] 
[fixed inappropriate shell raise
[EMAIL PROTECTED] 
[fixed ambiguity error
[EMAIL PROTECTED] 
[updated ClientForm
[EMAIL PROTECTED] 
[bumped to a2
[EMAIL PROTECTED] 
[fixed dns_check error
[EMAIL PROTECTED] 
[updated with Bob Halley's suggestions
[EMAIL PROTECTED] 
[updated dns_check stuff with tests & minimal docs
[EMAIL PROTECTED] 
[added dns_check
[EMAIL PROTECTED] 
[allowed failed setuptools import in setup.py; fail over to distutils
[EMAIL PROTECTED] 
[command-line completion etc now works for extend_with commands
[EMAIL PROTECTED] 
[major shell.py patch to allow for dynamic addition of shell commands with extend_with
[EMAIL PROTECTED] 
[bump to 0.8.5
[EMAIL PROTECTED] 
[fixed match_parse inclusion in 0.8.4
**20060324062448] 
[0.8.4 RELEASE
[EMAIL PROTECTED] 
[TAG release-0.8.4
[EMAIL PROTECTED] 
Patch bundle hash:
1f2883575a71280d09df9edcb9052ea17082578e
_______________________________________________
twill mailing list
[email protected]
http://lists.idyll.org/listinfo/twill

Reply via email to