简体   繁体   English

无法在Appium iOS测试上滑动

[英]Cannot swipe on appium iOS test

In the documentation, appium presents the following option for java: 在文档中,appium为java提供了以下选项:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", 0.01);
swipeObject.put("startY", 0.5);
swipeObject.put("endX", 0.95);
swipeObject.put("endY", 0.5);
swipeObject.put("duration", 1.8);
js.executeScript("mobile: swipe", swipeObject);

I integrated this in my test, but after navigating to the screen where swipe would be available, the method with swipe won't perform the action... In the failure exception panel I receive the following error: "org.openqa.selenium.WebDriverException: Not yet implemented". 我将其集成到了测试中,但是在导航到可以进行滑动的屏幕之后,使用滑动的方法将无法执行操作...在失败异常面板中,我收到以下错误:“ org.openqa.selenium。 WebDriverException:尚未实现”。

I want to swipe from left to right, but did not find another solution yet... 我想从左向右滑动,但还没有找到其他解决方案...

UPDATE: I have managed to swipe by using the following code: 更新:我已经设法通过使用以下代码来刷卡:

HashMap scrollObject = new HashMap();{{
    scrollObject.put("direction", "left");
}};
((RemoteWebDriver) driver).executeScript("mobile: scroll", scrollObject);

The problem is, that it will only swipe once, even if used multiple times... any ideas on how to solve this? 问题是,即使多次使用,它也只会滑动一次...关于如何解决此问题的任何想法?

如何使用IOSDriver(驱动程序)并调用以下命令:

    driver.swipe(100, 100, 500, 500, 500);

please refer detailed RCA of this issue with solution 请参考此问题的详细RCA和解决方案

Issue is for iOS appium java client had implmeneted swipe function differently! 问题是iOS appium java客户端具有不同的滑动功能!

for Android it stands with their parameter names endx and endy which are end point coordinates! 对于Android,其参数名称为endx和endy,它们是端点坐标!

But for iOS they are deltaX and deltaY if named correctly. 但是对于iOS,如果命名正确,则分别为deltaX和deltaY。

in nutshell, 简而言之,

Positive endx = Right direction and magnitude of endx defines swipe size
Negative endx = Left direction and magnitude of endx defines swipe size
Positive endy = Down direction and magnitude of endy defines swipe size
Negative endy = UP direction and magnitude of endy defines swipe size

StartX and StartY are coordinates of your start point of the stroke! StartX和StartY是笔画起点的坐标!

Lets take example 让我们举个例子

1. swipe(100,200,10,20,300) => swipe starting from Point (100,200) and end at Point (110,220) which means finger would move Right lower side fro current position
2. swipe(100,200,-10,20,300) => swipe starting from Point (100,200) and end at Point (90,220) which means finger would move Left lower side from current position
3. swipe(100,200,10,-20,300)=> swipe starting from Point (100,200) and end at Point (110,180) which means finger would move Right Upper side from current position
4. swipe(100,200,-10,-20,300)=> swipe starting from Point (100,200) and end at Point (90,180) which means finger would move Left Upper side from current position

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM