status-desktop/test/e2e/gui/elements/scroll.py

29 lines
1.0 KiB
Python
Raw Normal View History

2023-09-13 07:47:51 +00:00
import logging
import time
import allure
import driver
from .object import QObject
LOG = logging.getLogger(__name__)
2023-09-13 07:47:51 +00:00
class Scroll(QObject):
2024-07-10 05:00:53 +00:00
@allure.step('Scroll vertical down to object {1}')
2024-09-08 07:33:42 +00:00
def vertical_scroll_down(self, element: QObject, timeout_sec: int = 5):
2024-07-10 05:00:53 +00:00
started_at = time.monotonic()
while not element.is_visible:
driver.mouse.scroll(self.object, self.object.width / 2, self.object.height / 2, 0, -30, 1, 0.1)
2024-07-10 05:00:53 +00:00
if time.monotonic() - started_at > timeout_sec:
raise LookupError(f'Object not found: {element}')
@allure.step('Scroll vertical up to object {1}')
def vertical_scroll_up(self, element: QObject, timeout_sec: int = 5):
started_at = time.monotonic()
while not element.is_visible:
driver.mouse.scroll(self.object, self.object.width / 2, self.object.height / 2, 0, 30, 1, 0.1)
2024-07-10 05:00:53 +00:00
if time.monotonic() - started_at > timeout_sec:
raise LookupError(f'Object not found: {element}')