[Zope3-checkins] SVN: Zope3/branches/3.3/ - Fixed bug #723: Testbrowser was handling multiple submit buttons with the

Christian Theune ct at gocept.com
Sun Dec 10 18:14:39 EST 2006


Log message for revision 71515:
  - Fixed bug #723: Testbrowser was handling multiple submit buttons with the
    same name incorrectly.
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  U   Zope3/branches/3.3/src/zope/testbrowser/browser.py
  U   Zope3/branches/3.3/src/zope/testbrowser/tests.py

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-12-10 23:00:47 UTC (rev 71514)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-12-10 23:14:38 UTC (rev 71515)
@@ -10,13 +10,16 @@
 
     Bugfixes
 
+      - Fixed bug #723: Testbrowser was handling multiple submit buttons with
+        the same name incorrectly.
+
       - Fixed HTML rendered by ItemsMultiDisplayWidget: The 'name' attribute
         is not allowed in list tags and 'type' has a different meaning.
 
       - Fileresources now also set the Cache-control headers on 304
         responses. This speeds up page loads a lot on pages with many
         resources.
-    
+
       - Fixed validate method of schema.Date, now it does not accept
         datetime objects anymore. this is needed because datetime and
         date values are not comparable

Modified: Zope3/branches/3.3/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/testbrowser/browser.py	2006-12-10 23:00:47 UTC (rev 71514)
+++ Zope3/branches/3.3/src/zope/testbrowser/browser.py	2006-12-10 23:14:38 UTC (rev 71515)
@@ -364,7 +364,7 @@
     def _clickSubmit(self, form, control, coord):
         self._start_timer()
         self.mech_browser.open(form.click(
-                    id=control.id, name=control.name, coord=coord))
+            id=control.id, name=control.name, label=control.value, coord=coord))
         self._stop_timer()
 
     def _changed(self):

Modified: Zope3/branches/3.3/src/zope/testbrowser/tests.py
===================================================================
--- Zope3/branches/3.3/src/zope/testbrowser/tests.py	2006-12-10 23:00:47 UTC (rev 71514)
+++ Zope3/branches/3.3/src/zope/testbrowser/tests.py	2006-12-10 23:14:38 UTC (rev 71515)
@@ -157,6 +157,48 @@
         set_next_response(body, headers, status, reason)
         browser.Browser.open(self, 'http://localhost/')
 
+def test_submit_duplicate_name():
+    """
+
+This test was inspired by bug #723 as testbrowser would pick up the wrong
+button when having the same name twice in a form.
+
+    >>> browser = Browser()
+
+When given a form with two submit buttons that have the same name:
+
+    >>> browser.open('''\
+    ... <html><body>
+    ...   <form action="." method="post" enctype="multipart/form-data">
+    ...      <input type="submit" name="submit_me" value="GOOD" />
+    ...      <input type="submit" name="submit_me" value="BAD" />
+    ...   </form></body></html>
+    ... ''') # doctest: +ELLIPSIS
+    GET / HTTP/1.1
+    ...
+
+We can specify the second button through it's label/value:
+
+    >>> browser.getControl('BAD')
+    <SubmitControl name='submit_me' type='submit'>
+    >>> browser.getControl('BAD').value
+    'BAD'
+    >>> browser.getControl('BAD').click() # doctest: +REPORT_NDIFF
+    POST / HTTP/1.1
+    Content-length: 176
+    Connection: close
+    Content-type: multipart/form-data; boundary=---------------------------100167997466992641913031254
+    Host: localhost
+    User-agent: Python-urllib/2.4
+    <BLANKLINE>
+    -----------------------------100167997466992641913031254
+    Content-disposition: form-data; name="submit_me"
+    <BLANKLINE>
+    BAD
+    -----------------------------100167997466992641913031254--
+    <BLANKLINE>
+"""
+
 def test_file_upload():
     """
 



More information about the Zope3-Checkins mailing list