使用 Appium 执行 swipe() 时提到的“步骤”是什么

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

这只是出于好奇和对该方法的实现一无所知,我正在查看 java 代码的 appium 服务器日志:

driver.swipe()

读取的服务器日志:

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

这里的22 steps是什么??

"steps" 表示在 "swipe" 操作期间将注入和发出多少微 "move" 操作。该值是根据设备的实际显示尺寸和您要滑动的起始坐标(滑动距离)计算得出的。通常,在微操作之间插入一个微小的延迟以模仿 "swiping".

这是 "Swipe" 命令实施的示例 source code

步数是内部滑动选项,根据您提供的滑动持续时间计算得出。它指示滑动操作应该以多少步完成。在您的示例中,整个滑动操作通过 22 个小的滑动步骤完成。如果您提供 duration to 0,您可能会找到 with steps: 0 而不是 steps:22。例如,

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

根据您为滑动指定的持续时间计算步骤

Math.round(duration * swipeStepsPerSec)

每秒滑动步数定义为

const swipeStepsPerSec = 28;

因此,如果您提供了 1 秒的滑动持续时间,则总步数将变为 28。您可以参考 appium android driver code here