2023-09-13 09:47:51 +02:00
|
|
|
import logging
|
2023-08-29 16:43:00 +02:00
|
|
|
import time
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
|
|
|
import driver
|
|
|
|
from .object import QObject
|
|
|
|
|
2023-12-01 14:58:22 +01:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-09-13 09:47:51 +02:00
|
|
|
|
2023-08-29 16:43:00 +02:00
|
|
|
|
|
|
|
class Scroll(QObject):
|
|
|
|
|
2024-07-10 12:00:53 +07:00
|
|
|
@allure.step('Scroll vertical down to object {1}')
|
2024-09-08 10:33:42 +03:00
|
|
|
def vertical_scroll_down(self, element: QObject, timeout_sec: int = 5):
|
2024-07-10 12:00:53 +07:00
|
|
|
started_at = time.monotonic()
|
|
|
|
while not element.is_visible:
|
2024-10-09 09:38:16 +03:00
|
|
|
driver.mouse.scroll(self.object, self.object.width / 2, self.object.height / 2, 0, -30, 1, 0.1)
|
2024-07-10 12:00:53 +07: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 09:38:16 +03:00
|
|
|
driver.mouse.scroll(self.object, self.object.width / 2, self.object.height / 2, 0, 30, 1, 0.1)
|
2024-07-10 12:00:53 +07:00
|
|
|
if time.monotonic() - started_at > timeout_sec:
|
2024-10-11 16:35:19 +03:00
|
|
|
raise LookupError(f'Object not found: {element}')
|