无法在 ios 上从下往上滑动 - appium [英] Cannot swipe from bottom to top on ios - appium

查看:35
本文介绍了无法在 ios 上从下往上滑动 - appium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 ios 上设置 wifi 状态,为此,我需要从控制中心底部向上滑动.

I would like to set the wifi status on ios and in order to do that, I need to to swipe up from the bottom the Control Center.

    dimension = driverWrapper.getIosDriver().manage().window().getSize();
    int middleX = dimension.getWidth() / 2;
    int y = dimension.getHeight();
   driverWrapper.getIosDriver().swipe(middleX,y-10,middleX,150,600);

在我将 java 客户端升级到 4.0.0 并将 appium 升级到 1.5.2 之前,它运行正常.

Before I upgraded java client to 4.0.0 and appium to 1.5.2 it worked correctly.

我收到以下错误:错误:VerboseError:点不在屏幕范围内

日志是:

[debug] [UIAuto] Socket data received (49 bytes)
[debug] [UIAuto] Got result from instruments: {"status":0,"value":{"width":320,"height":568}}
[MJSONWP] Responding to client with driver.getWindowSize() result: {"width":320,"height":568}
[HTTP] <-- GET /wd/hub/session/31411e39-f408-418f-b9b8-e28b80ba1b35/window/current/size 200 1071 ms - 98 
[HTTP] --> POST /wd/hub/session/31411e39-f408-418f-b9b8-e28b80ba1b35/touch/perform {"actions":[{"action":"press","options":{"x":160,"y":558}},{"action":"wait","options":{"ms":100}},{"action":"moveTo","options":{"x":160,"y":284}},{"action":"release","options":{}}]}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":160,"y":558}},{"action":"wait","options":{"ms":100}},{"action":"moveTo","options":{"x":160,"y":284}},{"action":"...
[debug] [iOS] Executing iOS command 'performTouch'
[debug] [UIAuto] Sending command to instruments: target.touch([{"touch":[{"x":160,"y":558}],"time":0.2},{"touch":[{"x":160,"y":558}],"time":0.30000000000000004},{"touch":[{"x":320,"y":842}],"time":0.5}])

[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000 Debug: Got new command 6 from instruments: target.touch([{"touch":[{"x":160,"y":558}],"time":0.2},{"touch":[{"x":160,"y":558}],"time":0.30000000000000004},{"touch":[{"x":320,"y":842}],"time":0.5}])

[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000 Debug: evaluating target.touch([{"touch":[{"x":160,"y":558}],"time":0.2},{"touch":[{"x":160,"y":558}],"time":0.30000000000000004},{"touch":[{"x":320,"y":842}],"time":0.5}])

[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000 Debug: target.touch(__NSCFArray)

[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000 Debug: point is not within the bounds of the screen

知道发生了什么吗?

谢谢

推荐答案

滑动方法Criteria(Only for IOS)避免这个错误

  1. 0

  1. 0 < startx + endx < width

0 <开始 + 结束 <高度

0 < starty + endy < Height

务实的永久解决方案

为了简化我们的日常生活,写下这样的函数

For to simplify our day to day life, write down a function like this

public void swipeFinger(startx, starty, endx, endy, duration) {
   driver.swipe(startx, starty, startx - endx, starty - endy, duration);
}

RCA 错误:VerboseError:点不在屏幕范围内

问题是 driver.swipe 方法的 endx 和 endy 输入参数对于 IOS 的实现方式不同.

Issue is endx and endy input parameters of the driver.swipe method is implemented differently for IOS.

对于 IOS 来说,它实际上是 deltaX 和 deltaY.看看这张图片,并考虑你的手指在原点(两个轴的交点).

It is actually deltaX and deltaY for IOS.Look at this image and Consider your finger is at the origin(intersection of both axis).

如果你想向下或向右滑动你的手指,你需要传递正的 endx 和 endy 正值,如果你想向上或从右向左滑动,你需要传递你想要滑动的像素的负值手指.

If you want to swipe your finger down or Right side you need to pass positive endx and endy positive value and if you want to swipe down to up or right to left you need to pass negative value of pixels you want to swipe your finger.

20 像素向右滑动

driver.swipe(startx, starty, 20, 0, duration)

driver.swipe(startx, starty, 20, 0, duration)

因为您不想在垂直方向移动手指,所以 y 始终为零!

because you do not want to move your finger in vertical direction so y is always zero!

20 像素向下滑动

driver.swipe(startx, starty, 0, 20, duration)

driver.swipe(startx, starty, 0, 20, duration)

因为您不想在水平方向移动手指,所以 x 始终为零!

because you do not want to move your finger in Horizontal direction so x is always zero!

现在向上和向左滑动动作

Now UP and Left swipe actions

20 像素向上滑动动作

driver.swipe(startx, starty, 0, -20, duration)

driver.swipe(startx, starty, 0, -20, duration)

20 像素左滑动作

driver.swipe(startx, starty, -20, 0, duration)

driver.swipe(startx, starty, -20, 0, duration)

这篇关于无法在 ios 上从下往上滑动 - appium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆