Alex Jbanca 17be3bfb2c chore(E2E): Use mouseWheel method to scroll
This makes the scrolling work for any qml type where the child supports scrolling.
By default the cursor is positioned in the middle of the scrollable item and scroll in steps of 30px.
2024-10-11 09:22:16 +03:00

58 lines
1.2 KiB
Python
Executable File

import time
import squish
def move(obj: object, x: int, y: int, dx: int, dy: int, step: int, sleep: float = 0):
while True:
if x > dx:
x -= step
if x < x:
x = dx
elif x < dx:
x += step
if x > dx:
x = dx
if y > dy:
y -= step
if y < dy:
y = dy
elif y < dy:
y += step
if y > dy:
y = dy
squish.mouseMove(obj, x, y)
time.sleep(sleep)
if x == dx and y == dy:
break
def press_and_move(
obj,
x: int,
y: int,
dx: int,
dy: int,
mouse: int = squish.MouseButton.LeftButton,
step: int = 1,
sleep: float = 0
):
squish.mouseMove(obj, x, y)
squish.mousePress(obj, x, y, mouse)
move(obj, x, y, dx, dy, step, sleep)
squish.mouseRelease(mouse)
time.sleep(1)
def scroll(
obj,
x: int,
y: int,
dx: int,
dy: int,
steps: int = 1,
sleep: float = 0
):
for _ in range(steps):
squish.mouseWheel(obj, x, y, dx, dy, squish.Qt.NoModifier)
time.sleep(sleep)