2023-09-13 07:47:51 +00:00
|
|
|
import logging
|
2023-08-29 14:43:00 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
|
|
|
import driver
|
|
|
|
from .object import QObject
|
|
|
|
|
2023-12-01 13:58:22 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-09-13 07:47:51 +00:00
|
|
|
|
2023-08-29 14:43:00 +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:
|
2024-10-09 06:38:16 +00:00
|
|
|
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:
|
2024-10-09 06:38:16 +00:00
|
|
|
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:
|
2024-10-11 13:35:19 +00:00
|
|
|
raise LookupError(f'Object not found: {element}')
|