[Zope3-checkins] SVN: Zope3/trunk/ - Fixed bug #723: Testbrowser
was handling multiple submit buttons with the
Christian Theune
ct at gocept.com
Sun Dec 10 18:00:47 EST 2006
Log message for revision 71514:
- Fixed bug #723: Testbrowser was handling multiple submit buttons with the
same name incorrectly.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/testbrowser/browser.py
U Zope3/trunk/src/zope/testbrowser/tests.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2006-12-10 22:50:23 UTC (rev 71513)
+++ Zope3/trunk/doc/CHANGES.txt 2006-12-10 23:00:47 UTC (rev 71514)
@@ -149,6 +149,9 @@
Bug fixes
+ - Fixed bug #723: Testbrowser was handling multiple submit buttons with
+ the same name incorrectly.
+
- Fixed behaviour of PasswordWidget to allow users not changing their
password when a password already exists.
Modified: Zope3/trunk/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/browser.py 2006-12-10 22:50:23 UTC (rev 71513)
+++ Zope3/trunk/src/zope/testbrowser/browser.py 2006-12-10 23:00:47 UTC (rev 71514)
@@ -369,7 +369,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/trunk/src/zope/testbrowser/tests.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/tests.py 2006-12-10 22:50:23 UTC (rev 71513)
+++ Zope3/trunk/src/zope/testbrowser/tests.py 2006-12-10 23:00:47 UTC (rev 71514)
@@ -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