[Erp5-report] r16573 - /erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Sep 24 14:21:35 CEST 2007
Author: vincent
Date: Mon Sep 24 14:21:34 2007
New Revision: 16573
URL: http://svn.erp5.org?rev=16573&view=rev
Log:
Define a new method to fill <select> fields. Usefull to avoid hardcoding values in test suites.
Modified:
erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
Modified: erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py?rev=16573&r1=16572&r2=16573&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py (original)
+++ erp5/trunk/utils/erp5mechanize/ERP5Mechanize.py Mon Sep 24 14:21:34 2007
@@ -106,6 +106,18 @@
self.selectMainForm()
self.browser[name] = value
+ def fillSelectFieldByPredicate(self, name, predicate):
+ """
+ Allow to select item(s) of a <select>-type field by iterating on
+ available items. All present values are iterated through, passed one by
+ one to "predicate", and selected if predicate returns a True value.
+ """
+ assert callable(predicate)
+ self.selectMainForm()
+ field = self.browser[name]
+ assert field.type == 'select'
+ self.fillField(name, [x.value for x in field.items if predicate(x)])
+
def timeOpen(self, request):
"""
Returns begin and end timestamps.
More information about the Erp5-report
mailing list