From 1b9e044f86cd69d8965a9f890e444f474cbc6d6b Mon Sep 17 00:00:00 2001 From: Vladimir Druzhinin Date: Wed, 26 Apr 2023 18:24:20 +0200 Subject: [PATCH] test(suite_onboarding): fix tests for reviewer local machine #9284 --- test/ui-test/src/configs/__init__.py | 1 + test/ui-test/src/configs/squish.py | 3 +++ test/ui-test/src/drivers/SquishDriver.py | 2 ++ test/ui-test/src/drivers/elements/base_element.py | 13 +++++++------ 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 test/ui-test/src/configs/__init__.py create mode 100644 test/ui-test/src/configs/squish.py diff --git a/test/ui-test/src/configs/__init__.py b/test/ui-test/src/configs/__init__.py new file mode 100644 index 00000000000..a47f6f22ada --- /dev/null +++ b/test/ui-test/src/configs/__init__.py @@ -0,0 +1 @@ +from . import squish diff --git a/test/ui-test/src/configs/squish.py b/test/ui-test/src/configs/squish.py new file mode 100644 index 00000000000..a6218900da2 --- /dev/null +++ b/test/ui-test/src/configs/squish.py @@ -0,0 +1,3 @@ + +UI_LOAD_TIMEOUT_MSEC = 5000 +APP_LOAD_TIMEOUT_MSEC = 60000 diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index d0f7588630a..21b08396adb 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -37,6 +37,8 @@ def start_application(app_name: str, attempt = 2): toplevelwindow.ToplevelWindow(squish.waitForObject(names.statusDesktop_mainWindow)).maximize() except RuntimeError: if attempt: + time.sleep(1) + [ctx.detach() for ctx in squish.applicationContextList()] start_application(app_name, attempt-1) else: raise diff --git a/test/ui-test/src/drivers/elements/base_element.py b/test/ui-test/src/drivers/elements/base_element.py index f72fb51ba33..05bad8e1f91 100644 --- a/test/ui-test/src/drivers/elements/base_element.py +++ b/test/ui-test/src/drivers/elements/base_element.py @@ -1,5 +1,6 @@ import typing +import configs import names import object import squish @@ -46,8 +47,8 @@ def is_selected(self) -> bool: @property def is_visible(self) -> bool: try: - return squish.waitForObject(self.object_name, 500).visible - except LookupError: + return squish.findObject(self.object_name).visible + except (LookupError, RuntimeError): return False def click( @@ -63,9 +64,9 @@ def click( button or squish.MouseButton.LeftButton ) - def wait_until_appears(self, timeout_sec: int = 5): - assert squish.waitFor(lambda: self.is_visible, timeout_sec * 1000), f'Object {self} is not visible' + def wait_until_appears(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC): + assert squish.waitFor(lambda: self.is_visible, timeout_msec), f'Object {self} is not visible' return self - def wait_until_hidden(self, timeout_sec: int = 5): - assert squish.waitFor(lambda: not self.is_visible, timeout_sec * 1000), f'Object {self} is not hidden' + def wait_until_hidden(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC): + assert squish.waitFor(lambda: not self.is_visible, timeout_msec), f'Object {self} is not hidden'