无法在ios - appium上从下到上滑动 [英] Cannot swipe from bottom to top on 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]收到套接字数据(49字节)
[debug] [UIAuto]得到乐器的结果:{status:0,value:{width:320,height:568}}
[MJSONWP]回应客户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}},{ 动作: 等待, 选项:{ MS:100}},{ 动作: 的moveTo, 选项:{ ×:160, y 的:284}},{action:release,options:{}}]}
[MJSONWP]用args调用AppiumDriver.performTouch():[[{action:press, 选项:{ ×:160, Y:558}},{ 动作: 等待, 选项:{ MS:100}},{ 动作: 的moveTo, options:{x:160,y:284}},{action:...
[debug] [iOS]执行iOS命令'performTouch'
[debug ] [UIAuto]向乐器发送命令: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调试:从乐器获得新命令6:target.touch([{touch:[{ X :160, Y :558}], 时间 :0.2},{ 触摸 :[{ × :160, Y :558}], 时间 :0.30000000000000004},{触摸 :[{ × :320, Y :842}], 时间:0.5}])
[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000调试:评估target.touch([{touch:[{x:160, Y:558}], 时间:0.2},{ 触摸:[{ ×:160, Y:558}], 时间:0.30000000000000004},{ 触摸:[{ x:320,y:842}],时间:0.5}])
[调试] [工具] [INST] 2016-06-19 07:39:13 + 0000调试:target.touch(__ NSCFArray)
[debug] [Instruments] [INST] 2016-06-19 07:39:13 +0000调试:点不在屏幕范围内
知道发生了什么事吗?
谢谢
滑动方法标准(仅适用于IOS)以避免此错误
-
0< startx + endx<宽度
-
0< starty + endy<高度
务实的永久性解决方案
为了简化我们的日常生活,请写下这样的函数
public void swipeFinger(startx,starty, endx,endy,duration){
driver.swipe(startx,starty,startx - endx,starty - endy,duration);
}
RCA for Error:VerboseError:point不在范围内屏幕
问题是对于IOS,driver.swipe方法的endx和endy输入参数的实现方式不同。
它实际上是IOS的deltaX和deltaY。看看这个图像并考虑你的手指在原点(两个轴的交点)。
如果您想要向下滑动手指或向右滑动,则需要传递正向endx和endy正值,如果需要要向上或从右向左滑动,您需要传递要滑动手指的像素值。
20像素向右滑动
driver.swipe(startx,starty,20,0,duration)
因为你不想移动y我们的手指在垂直方向上,所以y总是为零!
20像素向下滑动
driver.swipe(startx,starty,0,20,duration)
因为你不想在水平方向上移动手指所以x总是为零! / p>
现在向上和向左滑动动作
20像素向上滑动动作
driver.swipe(startx,starty,0,-20,持续时间)
20像素左扫动作
driver.swipe(startx,starty,-20,0,duration)
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);
Before I upgraded java client to 4.0.0 and appium to 1.5.2 it worked correctly.
I get an error of: Error: VerboseError: point is not within the bounds of the screen
The logs are:
[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
Any idea what is going on?
Thanks
Swipe method Criteria(Only for IOS) to avoid this error
0 < startx + endx < width
0 < starty + endy < Height
Pragmatic permanent solution
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 for Error: VerboseError: point is not within the bounds of the screen
Issue is endx and endy input parameters of the driver.swipe method is implemented differently for IOS.
It is actually deltaX and deltaY for IOS.Look at this image and Consider your finger is at the origin(intersection of both axis).
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 pixel Right Swipe
driver.swipe(startx, starty, 20, 0, duration)
because you do not want to move your finger in vertical direction so y is always zero!
20 pixel Down Swipe
driver.swipe(startx, starty, 0, 20, duration)
because you do not want to move your finger in Horizontal direction so x is always zero!
Now UP and Left swipe actions
20 pixel UP Swipe Action
driver.swipe(startx, starty, 0, -20, duration)
20 pixel Left Swipe Action
driver.swipe(startx, starty, -20, 0, duration)
这篇关于无法在ios - appium上从下到上滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!