java - ios - appium 无法从下往上滑动

标签 java selenium 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

知道发生了什么吗?

谢谢

最佳答案

刷卡方法标准(仅适用于IOS)以避免此错误

  1. 0 <起始x + 结束x <宽度

  2. 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, 持续时间)

关于java - ios - appium 无法从下往上滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37905249/

相关文章:

java - Xpath 写入一个没有任何唯一 id 的元素

java - 令人困惑的 java.lang.NoSuchMethodError

css - Selenium Webdriver XPATH 我可以找到包含某些文本的标签,但我无法在标签标签上方获得输入标签复选框

python - 用户 :pass proxies with selenium

javascript - AngularJS 和 Protractor - 在元素 .isDisplayed() 时执行 .click()

selenium-webdriver - 未知错误 : an X display is required for keycode conversions

java - 安卓+Appium : Scroll inside ListView to specific position and click on it

java - 将 linux 命令行输出发送到另一个 screen

java - 并发编程是更加网格化还是更加集群化?

java - 无法使用扫描仪读取 Double