【问题标题】:Appium IOSDriver.swipe doesn't work anymore?Appium IOSDriver.swipe 不再起作用了?
【发布时间】:2017-02-19 19:24:06
【问题描述】:

我习惯用这个代码从右向左滑动:

appiumDriver.context("NATIVE_APP");
Dimension size = appiumDriver.manage().window().getSize();
int startx = (int) (size.width * 0.8);
int endx = (int) (size.width * 0.20);
int starty = size.height / 2;
appiumDriver.swipe(startx, starty, endx, starty, 500);

它应该是从右向左滑动的,之前它工作得很好(我有一个 CI)。但是现在已经不行了,而且我看到在真机上运行测试时,它从左向右滑动!

有谁知道是否不再支持这种方法的滑动?如果有任何解决方案?谢谢

【问题讨论】:

  • 您是否遇到任何异常或崩溃?这可能是由于出现了 iOS 放大镜。如果这是问题,您可以通过使用 swipe 方法减少 duration 参数来解决它。

标签: ios automated-tests appium swipe appium-ios


【解决方案1】:

是的,appiumDriver 现在不支持这个方法,不知道为什么。

下面的代码对我有用,你可以试一试,touchShortcuts 在这里真的很神奇。

((TouchShortcuts) driver).swipe(startx, starty, endx, starty, 500);

【讨论】:

  • 感谢您的回复,但 TouchShortcuts 对我不起作用(有一个警告:将 'appiumDriver' 转换为 'TouchShortcuts' 是多余的)。它仍然从左向右滑动,而不是完全滑动。
  • 在您的代码点中,x 总是会变小而 y 会变大,所以它只会从左向右滑动。请将乘法部分更改为相反,即 int startx = (int) (size.width * 0.20); int endx = (int) (size.width * 0.8);请试一试,让我知道它是否有效。
  • 您好,感谢您的跟进。我将代码更改为 appiumDriver.swipe(startx, starty, -(startx - 20), starty, 1000);它完成了工作。在 Appium 服务器日志中,滑动方法发生了变化,所以我也相应地更改了代码
  • 太好了,很高兴听到这个消息:)
猜你喜欢
  • 2015-05-20
  • 1970-01-01
  • 2022-11-10
  • 1970-01-01
  • 2022-06-12
  • 2014-10-18
  • 2016-02-22
  • 2019-01-04
  • 1970-01-01
相关资源
最近更新 更多