Hello everyone!<br><br>First of all, I&#39;d like to thank everyone involved with the twill project for creating and maintaining a very useful tool!<br><br>To time-deprived readers, I&#39;ll explain it briefly:<br><br>My problem is that unnamed forms that sit on a page that have a named form that has the unnamed form&#39;s number as part of its name cannot be accessed through regular fv&#39;s. For instance, if form #1 is named &quot;Form-123&quot; then unnamed forms #2 and #3 cannot be accessed by fv (2, , ) or fv ( &quot;3&quot;, , ) because the numbers 2 and 3 and the strings &quot;2&quot; and &quot;3&quot; are matched to the &quot;Form-123&quot; form.
<br><br>I suppose that a pretty solution would be to subclass the twill browser and add a matching process that prioritizes number matching. But I cannot do so right now. <br>&nbsp;<br>So I made an ugly workaround: I set the unnamed form to a certain name and use it normally onwards, through the set name.
<br><br>To those who need more info, I&#39;ll explain in length:<br><br>We at <a href="http://stoa.usp.br/">http://stoa.usp.br/</a> are beginning to use twill to monitor our site for any &quot;system breaks&quot; that might follow one of the developers submitting poor code.
<br><br>Recently, we started using a Google-provided form that makes searches in our site. With this, our main page has the following forms:<br><br>&gt;&gt;&gt; showforms()<br><br>Form name=searchform (#1)<br>## ## __Name__________________ __Type___ __ID________ __Value__________________
<br>1&nbsp;&nbsp;&nbsp;&nbsp; tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>2&nbsp;&nbsp;&nbsp;&nbsp; user_type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;&#39;] of [&#39;&#39;, &#39;person&#39;, &#39;community&#39;,&nbsp; ... <br>3&nbsp; 1&nbsp; None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ok 
<br><br><br>Form name=searchbox_006456382451512069951:41lst14sjem (#2)<br>## ## __Name__________________ __Type___ __ID________ __Value__________________<br>1&nbsp;&nbsp;&nbsp;&nbsp; cx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 006456382451512069951:41lst14sjem 
<br>2&nbsp;&nbsp;&nbsp;&nbsp; cof&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FORID:0 <br>3&nbsp;&nbsp;&nbsp;&nbsp; q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>4&nbsp; 1&nbsp; sa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Search <br><br><br>Form #3<br>## ## __Name__________________ __Type___ __ID________ __Value__________________
<br>1&nbsp;&nbsp;&nbsp;&nbsp; username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>2&nbsp;&nbsp;&nbsp;&nbsp; password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password&nbsp; password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>3&nbsp;&nbsp;&nbsp;&nbsp; passthru_url&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://stoa.usp.br/">http://stoa.usp.br/
</a> <br>4&nbsp;&nbsp;&nbsp;&nbsp; action&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log_on <br>5&nbsp; 1&nbsp; submit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ok <br>6&nbsp;&nbsp;&nbsp;&nbsp; remember&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checkbox&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;on&#39;] of [&#39;on&#39;] 
<br><br>As you can see, form #2 is the Google-provided form, with a long string as its name, and this string contains numbers, note specially that it contains the numbers 1 and 3.<br><br>Now, I need to fv the unnamed form #3, but if I try it directly I get an error:
<br><br>&gt;&gt;&gt; fv (3, &quot;username&quot;, &quot;test&quot;)<br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>&nbsp; File &quot;/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg
/twill/commands.py&quot;, line 428, in formvalue<br>&nbsp;&nbsp;&nbsp; control = browser.get_form_field(form, fieldname)<br>&nbsp; File &quot;/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg/twill/browser.py&quot;, line 366, in get_form_field
<br>&nbsp;&nbsp;&nbsp; raise Exception(&#39;no field matches &quot;%s&quot;&#39; % (fieldname,))<br>Exception: no field matches &quot;username&quot;<br>&gt;&gt;&gt; fv (&quot;3&quot;, &quot;username&quot;, &quot;test&quot;)<br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>&nbsp; File &quot;/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg/twill/commands.py&quot;, line 428, in formvalue<br>&nbsp;&nbsp;&nbsp; control = browser.get_form_field(form, fieldname)
<br>&nbsp; File &quot;/usr/lib/python2.4/site-packages/twill-0.9b1-py2.4.egg/twill/browser.py&quot;, line 366, in get_form_field<br>&nbsp;&nbsp;&nbsp; raise Exception(&#39;no field matches &quot;%s&quot;&#39; % (fieldname,))<br>Exception: no field matches &quot;username&quot;
<br><br>The reason is that twill matches 3 or &quot;3&quot; first to the Google-provided form, because it has the number 3 as part of it&#39;s string name! I get the &quot;no field matches&quot; error because there is no &quot;username&quot; at the Google-provided form!
<br><br>Now I hope there is a better way to solve this issue (other than rewriting the site), but I came up with this ugly solution:<br><br>I retrieve a forms list with a call to a browser object&#39;s get_all_forms() method;
<br>I name the third form as &quot;login&quot;;<br>I use the string &quot;login&quot; to use such form, instead of using the number 3.<br><br>It works, check it out:<br><br>&gt;&gt;&gt; b = get_browser()<br>&gt;&gt;&gt; b.get_all_forms
()[2].name = &quot;login&quot;<br>&gt;&gt;&gt; fv (&quot;login&quot;, &quot;username&quot;, &quot;test&quot;)<br>&gt;&gt;&gt; showforms()<br><br>Form name=searchform (#1)<br>## ## __Name__________________ __Type___ __ID________ __Value__________________
<br>1&nbsp;&nbsp;&nbsp;&nbsp; tag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>2&nbsp;&nbsp;&nbsp;&nbsp; user_type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;&#39;] of [&#39;&#39;, &#39;person&#39;, &#39;community&#39;,&nbsp; ... <br>3&nbsp; 1&nbsp; None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ok 
<br><br><br>Form name=searchbox_006456382451512069951:41lst14sjem (#2)<br>## ## __Name__________________ __Type___ __ID________ __Value__________________<br>1&nbsp;&nbsp;&nbsp;&nbsp; cx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 006456382451512069951:41lst14sjem 
<br>2&nbsp;&nbsp;&nbsp;&nbsp; cof&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FORID:0 <br>3&nbsp;&nbsp;&nbsp;&nbsp; q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>4&nbsp; 1&nbsp; sa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Search <br><br><br>Form name=login (#3)
<br>## ## __Name__________________ __Type___ __ID________ __Value__________________<br>1&nbsp;&nbsp;&nbsp;&nbsp; username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username&nbsp;&nbsp;&nbsp;&nbsp; test <br>2&nbsp;&nbsp;&nbsp;&nbsp; password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password&nbsp; password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>3&nbsp;&nbsp;&nbsp;&nbsp; passthru_url&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<a href="http://stoa.usp.br/">http://stoa.usp.br/</a> <br>4&nbsp;&nbsp;&nbsp;&nbsp; action&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidden&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log_on <br>5&nbsp; 1&nbsp; submit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; submit&nbsp;&nbsp;&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ok <br>6&nbsp;&nbsp;&nbsp;&nbsp; remember&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checkbox&nbsp; (None)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [&#39;on&#39;] of [&#39;on&#39;] 
<br><br>Well, I know it ain&#39;t pretty, but it works. At least until the developers change the front page again. I thought this would be of interest to anyone having problems with named and unnamed forms on the same page: the problem is, possibly due to a form that has numbers as part of its name.
<br><br>Again, I&#39;d like to thank Titus and the rest of the crew. Great work!<br><br>See ya!<br>Renato.<br><br>