What are the `steps` mentioned while executing swipe() using Appium
Asked Answered
W

2

10

This is just out of curiosity and cluelessness about the implementation of the method, I was going through the appium server logs for the java code :

driver.swipe()

Server Logs read :

info: [debug] [BOOTSTRAP] [debug] Swiping from [x=540.0, y=1066.0] to [x=540.0, y=710.0] with steps: 22

What are the 22 steps here??

Whirly answered 7/4, 2016 at 10:3 Comment(0)
C
3

Steps are internal swipe option and calculated from the duration you had provided to perform swipe. It indicates in how many steps the swipe action should be completed. In your example the entire swipe action get completed with 22 small swipe steps. if you provide duration to 0 you may found with steps: 0 instead of steps:22. For instance,

info: [debug] [BOOTSTRAP] [debug] Swiping from [x=540.0, y=1066.0] to [x=540.0, y=710.0] with steps: 0

Step are calculated based on the duration you specified for the swipe

Math.round(duration * swipeStepsPerSec)

Per second swipe steps are defined as

const swipeStepsPerSec = 28;

so if you had provided swipe duration of 1sec total steps will became 28. You can refer appium android driver code here.

Couchman answered 17/5, 2016 at 6:27 Comment(1)
would you be kind enough to help me understand to get to a solution for this #39485482Furbish
F
2

The "steps" indicates how many micro "move" actions would be injected and issued during the "swipe" action. The value is calculated depending on the actual display size of the device and the coordinates you want to make the swipe from and to (the swipe distance). Typically, there is a tiny delay inserted between the micro actions to imitate the "swiping".

Here is the sample source code of the "Swipe" command implementation.

Flak answered 16/5, 2016 at 20:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.