[Zope3-checkins] SVN: Zope3/branches/3.2/src/zope/testbrowser/
Commit trunk r71524: Fix a regression, with test
Gary Poster
gary at zope.com
Mon Dec 11 12:12:55 EST 2006
Log message for revision 71526:
Commit trunk r71524: Fix a regression, with test
Changed:
U Zope3/branches/3.2/src/zope/testbrowser/browser.py
U Zope3/branches/3.2/src/zope/testbrowser/tests.py
-=-
Modified: Zope3/branches/3.2/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/branches/3.2/src/zope/testbrowser/browser.py 2006-12-11 16:56:53 UTC (rev 71525)
+++ Zope3/branches/3.2/src/zope/testbrowser/browser.py 2006-12-11 17:12:54 UTC (rev 71526)
@@ -353,9 +353,14 @@
return Form(self, form)
def _clickSubmit(self, form, control, coord):
+ labels = control.get_labels()
+ if labels:
+ label = labels[0].text
+ else:
+ label = None
self._start_timer()
self.mech_browser.open(form.click(
- id=control.id, name=control.name, label=control.value, coord=coord))
+ id=control.id, name=control.name, label=label, coord=coord))
self._stop_timer()
def _changed(self):
Modified: Zope3/branches/3.2/src/zope/testbrowser/tests.py
===================================================================
--- Zope3/branches/3.2/src/zope/testbrowser/tests.py 2006-12-11 16:56:53 UTC (rev 71525)
+++ Zope3/branches/3.2/src/zope/testbrowser/tests.py 2006-12-11 17:12:54 UTC (rev 71526)
@@ -199,6 +199,38 @@
BAD
...
<BLANKLINE>
+
+This also works if the labels have whitespace around them (this tests a
+regression caused by the original fix for the above):
+
+ >>> 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
+ ...
+ >>> browser.getControl('BAD')
+ <SubmitControl name='submit_me' type='submit'>
+ >>> browser.getControl('BAD').value
+ ' BAD '
+ >>> browser.getControl('BAD').click() # doctest: +REPORT_NDIFF +ELLIPSIS
+ POST / HTTP/1.1
+ Content-length: ...
+ Connection: close
+ Content-type: multipart/form-data; boundary=...
+ Host: localhost
+ User-agent: Python-urllib/2.4
+ <BLANKLINE>
+ ...
+ Content-disposition: form-data; name="submit_me"
+ <BLANKLINE>
+ BAD
+ ...
+ <BLANKLINE>
+
"""
More information about the Zope3-Checkins
mailing list