mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-08 20:56:39 +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
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
import time
|
|
import typing
|
|
|
|
import allure
|
|
|
|
import configs
|
|
import driver
|
|
from gui.elements.qt.object import QObject
|
|
|
|
|
|
class List(QObject):
|
|
|
|
@property
|
|
@allure.step('Get list items {0}')
|
|
def items(self):
|
|
return [self.object.itemAtIndex(index) for index in range(self.object.count)]
|
|
|
|
@allure.step('Get values of list items {0}')
|
|
def get_values(self, attr_name: str) -> typing.List[str]:
|
|
values = []
|
|
for index in range(self.object.count):
|
|
value = str(getattr(self.object.itemAtIndex(index), attr_name, ''))
|
|
if value:
|
|
values.append(value)
|
|
return values
|
|
|
|
@allure.step('Select item {1} in {0}')
|
|
def select(self, value: str, attr_name: str):
|
|
driver.mouseClick(self.wait_for_item(value, attr_name))
|
|
|
|
@allure.step('Wait for item {1} in {0} with attribute {2}')
|
|
def wait_for_item(self, value: str, attr_name: str, timeout_sec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC):
|
|
started_at = time.monotonic()
|
|
values = []
|
|
while True:
|
|
for index in range(self.object.count):
|
|
cur_value = str(getattr(self.object.itemAtIndex(index), attr_name, ''))
|
|
if cur_value == value:
|
|
return self.object.itemAtIndex(index)
|
|
values.append(cur_value)
|
|
time.sleep(1)
|
|
if time.monotonic() - started_at > timeout_sec:
|
|
raise RuntimeError(f'value not found in list: {values}')
|