tests: fix start application issue (#10505)

- two attempts added
This commit is contained in:
Vladimir Druzhinin 2023-05-02 17:54:27 +02:00 committed by GitHub
parent 96a2310df0
commit c85cead983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -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.

View File

@ -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):