首页 > 解决方案 > 如果持续时间较长,如何在 Appium iOS 中添加同时移动的触摸?

问题描述

我的应用程序中有一个UIView。它接收UITouch-es,并且对其处理具有相当复杂的逻辑。处理逻辑依赖于 UIKit 触摸界面。

我不知道如何用 和 重现这种TouchAction情况MultiAction。有 2 次触摸。touch2启动较晚,持续时间较短: 在此处输入图像描述

在瞬间t3t4触摸同时移动,然后触摸2结束,但触摸1仍然移动。
我当前不工作的代码:https ://gist.github.com/gatamar/c7182292a1b54379cc26f3e38c823199

在 UIKit 中,触摸事件如下所示:

touchesBegan: [touch1_t1]
touchesBegan: [touch2_t2]
touchesMoved: [touch1_t3, touch2_t3]
touchesMoved: [touch1_t4, touch2_t4]
touchesEnded: [touch2_t4]
touchesMoved: [touch1_t5]
touchesEnded: [touch1_t5]

Appium 可以做到这一点吗?

可以MultiAction执行两个非同时触摸吗?

Python Appium Client 中是否有更底层的 API,例如 Selenium、XCUITest?

任何帮助将不胜感激。

标签: appiumappium-iosxcuitestpython-appium

解决方案


那好吧。这是在 Java 中使用手势的示例。

PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Dimension size = driver.manage().window().getSize();
//get your screen size
Point source = new Point(size.getWidth(), size.getHeight());
//this is resolution of your screen 
Sequence pinch = new Sequence(finger, 0);
pinch.addAction(finger.createPointerMove(Duration.ofMillis(0),
                PointerInput.Origin.viewport(), source.x / 2, source.y / 2));
pinch.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
pinch.addAction(new Pause(finger, Duration.ofMillis(100)));
pinch.addAction(finger.createPointerMove(Duration.ofMillis(600),
                    PointerInput.Origin.viewport(), source.x / 3, source.y / 3));

然后你需要perform通过调用来获得那个序列 driver.perform(Arrays.asList(pinchAndZoom1)); 如你所见,你可以修改手势的持续时间,玩弄它,你就会明白它是如何工作的。这里还有一些带有示例的文档。


推荐阅读