[Erp5-report] r44875 arnaud.fontaine - /erp5/trunk/utils/erp5.utils.test_browser/examples/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Mar 31 11:53:14 CEST 2011
Author: arnaud.fontaine
Date: Thu Mar 31 11:53:14 2011
New Revision: 44875
URL: http://svn.erp5.org?rev=44875&view=rev
Log:
Add code within the example to show to use listboxes
Modified:
erp5/trunk/utils/erp5.utils.test_browser/examples/testAddPerson.py
Modified: erp5/trunk/utils/erp5.utils.test_browser/examples/testAddPerson.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.utils.test_browser/examples/testAddPerson.py?rev=44875&r1=44874&r2=44875&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.utils.test_browser/examples/testAddPerson.py [utf8] (original)
+++ erp5/trunk/utils/erp5.utils.test_browser/examples/testAddPerson.py [utf8] Thu Mar 31 11:53:14 2011
@@ -5,7 +5,7 @@ from erp5.utils.test_browser.browser imp
ITERATION = 20
-def benchmarkAddPerson(result_dict):
+def benchmarkAddPerson(iteration_counter, result_dict):
"""
Benchmark adding a person.
"""
@@ -27,8 +27,11 @@ def benchmarkAddPerson(result_dict):
assert browser.getTransitionMessage() == 'Object created.'
# Fill the first and last name of the newly created person
- browser.mainForm.getControl(name='field_my_first_name').value = 'Foo'
- browser.mainForm.getControl(name='field_my_last_name').value = 'Bar'
+ browser.mainForm.getControl(name='field_my_first_name').value = 'Foo%d' % \
+ iteration_counter
+
+ browser.mainForm.getControl(name='field_my_last_name').value = 'Bar%d' % \
+ iteration_counter
# Submit the changes, record the time elapsed in seconds
result_dict.setdefault('Save', []).append(
@@ -45,13 +48,39 @@ def benchmarkAddPerson(result_dict):
# Check whether it has been successfully validated
assert browser.getTransitionMessage() == 'Status changed.'
+
+ ## Go to the new person from the Persons module, showing how to use
+ ## listbox API
+ # Go to Persons module first (person_module)
+ browser.mainForm.submitSelectModule(value='/person_module')
+
+ # Select all the persons whose Usual Name starts with Foo
+ browser.mainForm.getListboxControl(2, 2).value = 'Foo%'
+
+ result_dict.setdefault('Filter', []).append(
+ browser.mainForm.timeSubmitInSecond())
+
+ # Get the line number
+ line_number = browser.getListboxPosition("Foo%(counter)d Bar%(counter)d" % \
+ {'counter': iteration_counter},
+ column_number=2)
+
+ # From the column and line_number, we can now get the Link instance
+ link = browser.getListboxLink(line_number=line_number, column_number=2)
+
+ # Click on the link
+ link.click()
+
+ assert browser.mainForm.getControl(name='field_my_first_name').value == \
+ 'Foo%d' % iteration_counter
+
if __name__ == '__main__':
# Run benchmarkAddPerson ITERATION times and compute the average time it
# took for each operation
result_dict = {}
counter = 0
while counter != ITERATION:
- benchmarkAddPerson(result_dict)
+ benchmarkAddPerson(counter, result_dict)
counter += 1
for title, time_list in result_dict.iteritems():
More information about the Erp5-report
mailing list