mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-10 13:46:35 +00:00
* test(pytest) The driver methods added. Wrappers for UI elements added. #67 * test(pytest) Squishserver added #68 * test(pytest) Attach/Detach AUT methods added #69 * test(pytest) Main window handler added #70 * test(pytest) Save screenshot on fail added #71 * test(pytest) Wait for squishserver added #71 * test(pytest) Setup Windows #71 * Generate new keys (#11804) * test(pytest) Image comparison methods added #76 * test(pytest) Tesseract methods added #77 * test(pytest) The Methods to search color on image added #80 * test(onboarding) Test on generation new keys added #75 * test(pytest) Handlers for OS Native File dialog added #81 * test(Onboarding) Test on Profile image added #83 * Allure and TestRail integration (#11806) * test(Allure) Steps descriptions added #72 * test(TestRail) Integration #72
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import time
|
|
from copy import deepcopy
|
|
|
|
import configs.timeouts
|
|
|
|
if configs.system.IS_MAC:
|
|
import atomacos
|
|
|
|
BUNDLE_ID = 'im.Status.NimStatusClient'
|
|
|
|
|
|
# https://pypi.org/project/atomacos/
|
|
|
|
|
|
def attach_atomac(timeout_sec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC):
|
|
atomator = atomacos.getAppRefByBundleId(BUNDLE_ID)
|
|
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}')
|