diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index 0808a85354..57e2a76556 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -28,12 +28,24 @@ _MAX_WAIT_OBJ_TIMEOUT = 5000 # The default minimum timeout to find ui object _MIN_WAIT_OBJ_TIMEOUT = 500 +# The default maximum time to application load +_MAX_WAIT_APP_TIMEOUT = 15000 + _SEARCH_IMAGES_PATH = "../shared/searchImages/" -def start_application(app_name: str): - squish.startApplication(app_name) - toplevelwindow.ToplevelWindow(squish.waitForObject(names.statusDesktop_mainWindow)).maximize() +def start_application(app_name: str, attempt=2): + try: + ctx = squish.startApplication(app_name) + assert squish.waitFor(lambda: ctx.isRunning, _MAX_WAIT_APP_TIMEOUT), 'Start application error' + toplevelwindow.ToplevelWindow(squish.waitForObject(names.statusDesktop_mainWindow)).maximize() + except (AssertionError, RuntimeError): + if attempt: + [ctx.detach() for ctx in squish.applicationContextList()] + time.sleep(1) + start_application(app_name, attempt - 1) + else: + raise # Waits for the given object is loaded, visible and enabled. diff --git a/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py b/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py index b60e25030d..8ab32f2b4f 100644 --- a/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py +++ b/test/ui-test/testSuites/global_shared/scripts/bdd_hooks.py @@ -14,8 +14,9 @@ def hook(context): @OnScenarioEnd def hook(context): - currentApplicationContext().detach() - snooze(_app_closure_timeout) + ctx = currentApplicationContext() + ctx.detach() + assert waitFor(lambda: not ctx.isRunning, _app_closure_timeout), 'Detach application failed' @OnStepEnd def hook(context):