From 4acb37fb410d99867b200e4fb1fbd167f7cf0f0e Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Thu, 31 Mar 2011 09:53:14 +0000 Subject: [PATCH] Add code within the example to show to use listboxes git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44875 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../test_browser/examples/testAddPerson.py | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/erp5/util/test_browser/examples/testAddPerson.py b/erp5/util/test_browser/examples/testAddPerson.py index 3037d720be..504fc5508b 100755 --- a/erp5/util/test_browser/examples/testAddPerson.py +++ b/erp5/util/test_browser/examples/testAddPerson.py @@ -5,7 +5,7 @@ from erp5.utils.test_browser.browser import Browser 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(): -- 2.30.9