[Zope3-checkins] SVN: Zope3/trunk/src/zope/testbrowser/ Fix a
regression, with test
Gary Poster
gary at zope.com
Mon Dec 11 11:42:05 EST 2006
Log message for revision 71524:
Fix a regression, with test
Changed:
U Zope3/trunk/src/zope/testbrowser/browser.py
U Zope3/trunk/src/zope/testbrowser/tests.py
-=-
Modified: Zope3/trunk/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/browser.py 2006-12-11 16:40:46 UTC (rev 71523)
+++ Zope3/trunk/src/zope/testbrowser/browser.py 2006-12-11 16:42:03 UTC (rev 71524)
@@ -367,9 +367,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/trunk/src/zope/testbrowser/tests.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/tests.py 2006-12-11 16:40:46 UTC (rev 71523)
+++ Zope3/trunk/src/zope/testbrowser/tests.py 2006-12-11 16:42:03 UTC (rev 71524)
@@ -197,6 +197,38 @@
BAD
-----------------------------100167997466992641913031254--
<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
+ 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