From 184c4720cb15f69689e5340532ec5986532c9a46 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Mon, 29 Aug 2011 08:21:26 +0000 Subject: [PATCH] Usually, a transition message will be displayed if it was not possible to jump (for example because the object has not been created yet), therefore the number of attempts before failing can now be specified. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@46005 20353a03-c40f-0410-a6d1-a30d3c3de9de --- erp5/util/test_browser/browser.py | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/erp5/util/test_browser/browser.py b/erp5/util/test_browser/browser.py index c0d30f80e6..78279340c4 100644 --- a/erp5/util/test_browser/browser.py +++ b/erp5/util/test_browser/browser.py @@ -759,15 +759,46 @@ class ContextMainForm(MainForm): - doContextReport - doContextExchange """ - def submitSelectJump(self, label=None, value=None, **kw): + def submitSelectJump(self, label=None, value=None, + no_jump_transition_message=None, + maximum_attempt_number=1, sleep_between_attempt=0, + **kw): """ Select and submit a jump, given either by its label (such as I{Queries}) or value (such as I{/person_module/Base_jumpToRelatedObject?portal_type=Foo}). See L{submitSelect}. + + Usually, a transition message will be displayed if it was not possible to + jump (for example because the object has not been created yet), therefore + the number of attempts before failing can be specified if necessary. + + @param no_jump_transition_message: Transition message displayed if the + jump could not be performed + @type no_jump_transition_message: str + @param maximum_attempt_number: Number of attempts before failing + @type maximum_attempt_number: int + @param sleep_between_attempt: Sleep N seconds between attempts + @type sleep_between_attempt: int + @return: The time spent (in seconds) if relevant + @rtype: int """ - self.submitSelect('select_jump', 'Base_doJump:method', label, value, - **kw) + if not no_jump_transition_message: + self.submitSelect('select_jump', 'Base_doJump:method', + label, value, **kw) + else: + current_attempt_number = 0 + while current_attempt_counter != maximum_attempt_number: + self.submitSelect('select_jump', 'Base_doJump:method', + label, value, **kw) + + if no_jump_transition_message != self.browser.getTransitionMessage(): + return current_attempt_counter * sleep_between_attempt + + time.sleep(sleep_between_attempt) + current_attempt_counter += 1 + + raise AssertionError("Could not jump to related object") def submitSelectAction(self, label=None, value=None, **kw): """ -- 2.30.9