首页 > 解决方案 > 无法让 I.swipeLeft() 或 I.swipeRight() 使用 Appium 在 CodeceptJS 中工作

问题描述

我正在测试一个原生 Android 应用程序,并希望能够在元素上向左滑动或向右滑动。我在这里阅读了文档:

https://codecept.io/helpers/Appium.html#swiperight

let locator = "#io.selendroid.testapp:id/LinearLayout1";
I.swipeRight(locator); // simple swipe
I.swipeRight(locator, 500); // set speed
I.swipeRight(locator, 1200, 1000); // set offset and speed

我无法让它工作。我很确定我有正确的定位器,因为当我执行 时I.tap(locator),它可以工作。

有没有人设法得到I.swipeRight(locator)I.swipeLeft(localtor)工作?

标签: testingappiumcodeceptjs

解决方案


我遇到了同样的问题。我在 iOS 而不是 Android 上这样做,但最终对我有用的是

I.executeScript('mobile: swipe', {direction: 'left'})

对于其他选项(可能是特定于平台的),您可能需要查看 Appium 文档(不特定于 CodeceptJS)。


推荐阅读