testdevlab / Py-TestUI

Apache License 2.0
17 stars 1 forks source link

New touch Actions can be very long to write, let's simplify swipes #61

Open alvarolaserna opened 9 months ago

alvarolaserna commented 9 months ago

Right now to make a single swipe we need to write all this code:

        appium_driver.actions().w3c_actions = ActionBuilder(
            appium_driver.get_driver,
            mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))

        actions = appium_driver.actions()
        actions.w3c_actions.pointer_action.move_to_location(x=500, y=10)
        actions.w3c_actions.pointer_action.pointer_down()
        actions.w3c_actions.pointer_action.pause(1)
        actions.w3c_actions.pointer_action.move_to_location(x=500, y=1000)
        actions.w3c_actions.pointer_action.release()
        actions.perform()

I propose to make a swipe method that works like this:

list_swipe = [{x1, y1}, {x2, y2}, {x3, y3}]
appium_driver.swipe(list_swipe)

This method will swipe going from P1 to P2 and to P3, and if the list is longer, then it will go to all those points.

TDL-EdgarsEglitis commented 9 months ago

I would suggest also adding a way to specify swipe duration. In my experience, swiping over longer distances translates to faster swipe speeds (since the duration stays the same), which leads to a higher chance of unwanted overscrolls. But this could also depend on the app.