微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Java-无法在iOS上从下往上滑动-Appium

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

    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之前,它可以正常工作.

我收到以下错误
错误: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(仅适用于IOS)可避免此错误

> 0< startx endx<宽度
> 0<始发端<高度
务实的永久解决方

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

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

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

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

对于IOS,它实际上是deltaX和deltaY.查看此图像并考虑手指在原点(两个轴的交点).

enter image description here

如果要向下或向右滑动手指,则需要传递正的endx和endy正值;如果要向下或向右滑动,则需要传递负值的像素来滑动手指.

20像素向右滑动

driver.swipe(startx,starty,20,0,持续时间)

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

20像素向下滑动

driver.swipe(startx,starty,0,20,持续时间)

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

现在向上和向左滑动动作

20像素向上滑动动作

driver.swipe(startx,starty,0,-20,持续时间)

20像素向左滑动动作

driver.swipe(startx,starty,-20,0,持续时间)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐