From 294119c08a39d1d856a81c92030e29d2321124ea Mon Sep 17 00:00:00 2001 From: Vladimir Druzhinin <128374224+StateOf-Vlado@users.noreply.github.com> Date: Tue, 7 Nov 2023 16:05:43 +0100 Subject: [PATCH] chore: squish waitFor method was customized (#272) #262 --- test/e2e/driver/__init__.py | 7 ++- test/e2e/driver/atomacos.py | 60 ------------------- test/e2e/driver/squish_api.py | 12 ++++ test/e2e/gui/components/color_select_popup.py | 4 +- .../gui/components/signing_phrase_popup.py | 2 - test/e2e/gui/screens/onboarding.py | 2 +- 6 files changed, 19 insertions(+), 68 deletions(-) delete mode 100644 test/e2e/driver/atomacos.py create mode 100644 test/e2e/driver/squish_api.py diff --git a/test/e2e/driver/__init__.py b/test/e2e/driver/__init__.py index 00f88059d9..8a5f878c95 100755 --- a/test/e2e/driver/__init__.py +++ b/test/e2e/driver/__init__.py @@ -1,17 +1,18 @@ +import time + import squishtest # noqa import configs -from . import server, context, objects_access, toplevel_window, aut, atomacos, mouse +from . import server, context, objects_access, toplevel_window, aut, mouse +from .squish_api import * imports = {module.__name__: module for module in [ - atomacos, aut, context, objects_access, mouse, server, toplevel_window - ]} diff --git a/test/e2e/driver/atomacos.py b/test/e2e/driver/atomacos.py deleted file mode 100644 index 95d96e185c..0000000000 --- a/test/e2e/driver/atomacos.py +++ /dev/null @@ -1,60 +0,0 @@ -import time -from copy import deepcopy - -import configs.timeouts -import driver - -if configs.system.IS_MAC: - from atomacos._a11y import _running_apps_with_bundle_id - import atomacos - -BUNDLE_ID = 'im.Status.NimStatusClient' - - -# https://pypi.org/project/atomacos/ - - -def attach_atomac(timeout_sec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC): - def from_bundle_id(bundle_id): - """ - Get the top level element for the application with the specified - bundle ID, such as com.vmware.fusion. - """ - apps = _running_apps_with_bundle_id(bundle_id) - if not apps: - raise ValueError( - "Specified bundle ID not found in " "running apps: %s" % bundle_id - ) - return atomacos.NativeUIElement.from_pid(apps[-1].processIdentifier()) - - pid = driver.currentApplicationContext().pid - atomator = atomacos.getAppRefByPid(pid) - started_at = time.monotonic() - while not hasattr(atomator, 'AXMainWindow'): - time.sleep(1) - assert time.monotonic() - started_at < timeout_sec, f'Attach error: {BUNDLE_ID}' - return atomator - - -def find_object(object_name: dict): - _object_name = deepcopy(object_name) - if 'container' in _object_name: - parent = find_object(_object_name['container']) - del _object_name['container'] - else: - return attach_atomac().windows()[0] - - assert parent is not None, f'Object not found: {object_name["container"]}' - _object = parent.findFirst(**_object_name) - assert _object is not None, f'Object not found: {_object_name}' - return _object - - -def wait_for_object(object_name: dict, timeout_sec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC): - started_at = time.monotonic() - while True: - try: - return find_object(object_name) - except AssertionError as err: - if time.monotonic() - started_at > timeout_sec: - raise LookupError(f'Object: {object_name} not found. Error: {err}') diff --git a/test/e2e/driver/squish_api.py b/test/e2e/driver/squish_api.py new file mode 100644 index 0000000000..163e544382 --- /dev/null +++ b/test/e2e/driver/squish_api.py @@ -0,0 +1,12 @@ +import time + +import configs.timeouts + + +def waitFor(condition, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC) -> bool: + started_at = time.monotonic() + while not condition(): + time.sleep(1) + if time.monotonic() - started_at > timeout_msec/1000: + return False + return True diff --git a/test/e2e/gui/components/color_select_popup.py b/test/e2e/gui/components/color_select_popup.py index 24ba88e29b..faa9549348 100644 --- a/test/e2e/gui/components/color_select_popup.py +++ b/test/e2e/gui/components/color_select_popup.py @@ -15,12 +15,12 @@ class ColorSelectPopup(BasePopup): @allure.step('Wait until appears {0}') def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): - self._hex_color_text_edit.wait_until_appears() + self._hex_color_text_edit.wait_until_appears(timeout_msec) return self @allure.step('Wait until hidden {0}') def wait_until_hidden(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): - self._hex_color_text_edit.wait_until_hidden() + self._hex_color_text_edit.wait_until_hidden(timeout_msec) @allure.step('Select color {1}') def select_color(self, value: str): diff --git a/test/e2e/gui/components/signing_phrase_popup.py b/test/e2e/gui/components/signing_phrase_popup.py index e22bd8e1fa..fc064f90f1 100644 --- a/test/e2e/gui/components/signing_phrase_popup.py +++ b/test/e2e/gui/components/signing_phrase_popup.py @@ -1,6 +1,5 @@ import allure -from gui.components.base_popup import BasePopup from gui.elements.button import Button from gui.elements.object import QObject @@ -19,4 +18,3 @@ class SigningPhrasePopup(QObject): @allure.step('Verify if the signing phrase popup is visible') def is_ok_got_it_button_visible(self): return self._ok_got_it_button.is_visible - diff --git a/test/e2e/gui/screens/onboarding.py b/test/e2e/gui/screens/onboarding.py index 24b9c7087f..27911b5dd5 100755 --- a/test/e2e/gui/screens/onboarding.py +++ b/test/e2e/gui/screens/onboarding.py @@ -179,7 +179,7 @@ class SyncResultView(OnboardingView): return device_synced_notifications @allure.step('Wait until appears {0}') - def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + def wait_until_appears(self, timeout_msec: int = 10000): self._sign_in_button.wait_until_appears(timeout_msec) return self