[Zope3-checkins] SVN: Zope3/branches/testbrowser-integration/src/zope/testbrowser/ Work on zope.testbrowser:

Benji York benji at zope.com
Sat Jul 30 11:56:06 EDT 2005


Log message for revision 37603:
  Work on zope.testbrowser:
   - browser.click now accepts strings to do substring searches, and compiled
     regular expression objects to do regex searches for "text" and "url"
     parameters
   - break out id, name, and text parameters to browser.getControl and
     form.getControl (less DWIMy)
  

Changed:
  U   Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt
  U   Zope3/branches/testbrowser-integration/src/zope/testbrowser/browser.py

-=-
Modified: Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt
===================================================================
--- Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt	2005-07-30 15:24:26 UTC (rev 37602)
+++ Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt	2005-07-30 15:56:06 UTC (rev 37603)
@@ -282,7 +282,7 @@
 But the value of a control is not always everything that there is to know or
 that is interesting. In those cases, one can access the control object:
 
-    >>> ctrl = browser.getControl('text-value')
+    >>> ctrl = browser.getControl(name='text-value')
     >>> ctrl
     <Control name='text-value' type='text'>
 
@@ -337,7 +337,7 @@
 
   - Password Control
 
-    >>> ctrl = browser.getControl('password-value')
+    >>> ctrl = browser.getControl(name='password-value')
     >>> ctrl
     <Control name='password-value' type='password'>
     >>> ctrl.value
@@ -354,7 +354,7 @@
 
   - Hidden Control
 
-    >>> ctrl = browser.getControl('hidden-value')
+    >>> ctrl = browser.getControl(name='hidden-value')
     >>> ctrl
     <Control name='hidden-value' type='hidden'>
     >>> ctrl.value
@@ -371,7 +371,7 @@
     
   - Text Area Control
 
-    >>> ctrl = browser.getControl('textarea-value')
+    >>> ctrl = browser.getControl(name='textarea-value')
     >>> ctrl
     <Control name='textarea-value' type='textarea'>
     >>> ctrl.value
@@ -388,7 +388,7 @@
 
   - File Control
 
-    >>> ctrl = browser.getControl('file-value')
+    >>> ctrl = browser.getControl(name='file-value')
     >>> ctrl
     <Control name='file-value' type='file'>
     >>> ctrl.value
@@ -405,7 +405,7 @@
 
   - Selection Control (Single-Valued)
 
-    >>> ctrl = browser.getControl('single-select-value')
+    >>> ctrl = browser.getControl(name='single-select-value')
     >>> ctrl
     <Control name='single-select-value' type='select'>
     >>> ctrl.value
@@ -420,7 +420,7 @@
 
   - Selection Control (Multi-Valued)
 
-    >>> ctrl = browser.getControl('multi-select-value')
+    >>> ctrl = browser.getControl(name='multi-select-value')
     >>> ctrl
     <Control name='multi-select-value' type='select'>
     >>> ctrl.value
@@ -435,7 +435,7 @@
 
   - Checkbox Control (Single-Valued; Unvalued)
 
-    >>> ctrl = browser.getControl('single-unvalued-checkbox-value')
+    >>> ctrl = browser.getControl(name='single-unvalued-checkbox-value')
     >>> ctrl
     <Control name='single-unvalued-checkbox-value' type='checkbox'>
     >>> ctrl.value
@@ -450,7 +450,7 @@
 
   - Checkbox Control (Single-Valued, Valued)
 
-    >>> ctrl = browser.getControl('single-valued-checkbox-value')
+    >>> ctrl = browser.getControl(name='single-valued-checkbox-value')
     >>> ctrl
     <Control name='single-valued-checkbox-value' type='checkbox'>
     >>> ctrl.value
@@ -465,7 +465,7 @@
 
   - Checkbox Control (Multi-Valued)
 
-    >>> ctrl = browser.getControl('multi-checkbox-value')
+    >>> ctrl = browser.getControl(name='multi-checkbox-value')
     >>> ctrl
     <Control name='multi-checkbox-value' type='checkbox'>
     >>> ctrl.value
@@ -480,7 +480,7 @@
 
   - Image Control
 
-    >>> ctrl = browser.getControl('image-value')
+    >>> ctrl = browser.getControl(name='image-value')
     >>> ctrl
     <Control name='image-value' type='image'>
     >>> ctrl.value
@@ -496,7 +496,7 @@
 
   - Submit Control
 
-    >>> ctrl = browser.getControl('submit-value')
+    >>> ctrl = browser.getControl(name='submit-value')
     >>> ctrl
     <Control name='submit-value' type='submit'>
     >>> ctrl.value
@@ -608,7 +608,7 @@
 Besides those attributes, you have also a couple of methods. Like for the
 browser, you can get control objects
 
-    >>> form.getControl('text-value')
+    >>> form.getControl(name='text-value')
     <Control name='text-value' type='text'>
 
 and submit the form:

Modified: Zope3/branches/testbrowser-integration/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/branches/testbrowser-integration/src/zope/testbrowser/browser.py	2005-07-30 15:24:26 UTC (rev 37602)
+++ Zope3/branches/testbrowser-integration/src/zope/testbrowser/browser.py	2005-07-30 15:56:06 UTC (rev 37603)
@@ -155,9 +155,9 @@
                 text_regex=text_regex, url_regex=url_regex)
         self._changed()
 
-    def getControl(self, text):
+    def getControl(self, text=None, id=None, name=None):
         """See zope.testbrowser.interfaces.IBrowser"""
-        form, control = self._findControl(text, text, text)
+        form, control = self._findControl(text, id, name)
         if control is None:
             raise ValueError('could not locate control: ' + text)
         return Control(control)
@@ -379,9 +379,9 @@
             self.browser._clickSubmit(form, control, coord)
             self.browser._changed()
 
-    def getControl(self, text):
+    def getControl(self, text=None, id=None, name=None):
         """See zope.testbrowser.interfaces.IForm"""
-        form, control = self.browser._findControl(text, text, text,
+        form, control = self.browser._findControl(text, id, name,
                                                   form=self.mech_form)
         if control is None:
             raise ValueError('could not locate control: ' + text)



More information about the Zope3-Checkins mailing list