Java 无法在ios-appium上从下向上滑动

Java 无法在ios-appium上从下向上滑动,java,selenium,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,

我想在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之前,它工作正常

我得到一个错误: 错误:详细错误:点不在屏幕范围内

记录如下:

[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
[debug][UIAuto]已接收套接字数据(49字节)
[debug][UIAuto]从工具获取结果:{“状态”:0,“值”:{“宽度”:320,“高度”:568}
[MJSONWP]使用驱动程序响应客户端。GetWindowsSize()结果:{“宽度”:320,“高度”:568}
[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]使用参数调用AppiumDriver.performTouch()[[{“action”:“press”,“options”:{“x”:160,“y”:558},{“action”:“wait”,“options”:{“ms”:100},{“action”:“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.300000000000000004},{“touch”:[{“x”:320,“y”:842}],“time”:0.5}])
[debug][INST][2016-06-19 07:39:13+0000调试:从仪器获得新命令6:target.touch([{“touch”:[{“x”:160,“y”:558}],“time”:0.2},{“touch”:[{“x”:160,“y”:558}],“time”:0.3000000000000000000000004},{“touch”:[{“x”:320,“y”:842}],“time”:0.5})
[调试][仪器][仪器][仪器]2016-06-19 07:39:13+0000调试:评估目标触摸({“触摸”:[{“x”:160,“y”:558}),“时间”:0.2},{“触摸”:[{“x”:160,“y”:558}],“时间”:0.3000000000000000004},{“触摸”:[{“x”:320,“y”:842}],“时间”:0.5})
[调试][仪器][仪器]2016-06-19 07:39:13+0000调试:目标触摸
[调试][仪器][仪器]2016-06-19 07:39:13+0000调试:点不在屏幕范围内
知道发生了什么吗

谢谢


检查此操作是否有效。如果不起作用,请尝试进一步减小y:0.01。

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

  • 0
  • 0<起点+终点<高度

  • 务实的永久解决方案

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

    public void swipeFinger(startx, starty, endx, endy, duration) {
       driver.swipe(startx, starty, startx - endx, starty - endy, duration);
    }
    
    RCA for Error:VerboseError:point不在屏幕范围内

    问题是驱动程序的endx和endy输入参数。对于IOS,滑动方法的实现方式不同

    这实际上是iOS的DelCuffy和Deltay.看看这个图像并考虑你的手指在原点(两个轴的交点).

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

    20像素右击

    驱动程序。轻扫(startx、starty、20、0、持续时间)

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

    20像素向下滑动

    驱动程序。滑动(开始、开始、0、20、持续时间)

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

    现在向上和向左滑动动作

    20像素向上滑动动作

    驱动程序。轻扫(startx,starty,0,-20,持续时间)

    20像素左扫动作


    驱动程序.swipe(startx,starty,-20,0,duration)

    使用Appium 1.6.5的iOS10的Python版本:

    def swipe_up(self):
    
    logging.info("swipe up")
    sleep(1)
    window_size = self.driver.get_window_size()  # this returns dictionary
    sleep(1)
    el = self.driver.find_element(*self.configuration.CommonScreen.WEB_VIEW)
    action = TouchAction(self.driver)
    sleep(1)
    start_x = window_size["width"] * 0.5
    start_y = window_size["height"]
    end_x = window_size["width"] * 0.5
    end_y = window_size["height"] * 0.5
    action.press(el, start_x, start_y).wait(100).move_to(el, end_x, end_y).release().perform()
    sleep(1)
    

    对于iOS9,您需要将wait更改为1000。

    您是否尝试将lie y-30作为startY?是的。从未成功过。我还尝试了:action=new TouchAction(DriverRapper.getIosDriver());action.press(middleX,y-1)。waitAction(1000)。moveTo(middleX,y/2)。release()。perform();使用TouchAction滑动方法本身!因此它显然不起作用!检查源代码!非常感谢您的帮助,但它仍然不起作用。我认为这是一个进步,因为现在我没有发现错误:点不在屏幕范围内。现在发生的是,滑动被忽略。它没有执行。滑动方法标准(仅适用于IOS)为避免此错误,1.startx+endx<宽度2.starty+endy<高度
    def swipe_up(self):
    
    logging.info("swipe up")
    sleep(1)
    window_size = self.driver.get_window_size()  # this returns dictionary
    sleep(1)
    el = self.driver.find_element(*self.configuration.CommonScreen.WEB_VIEW)
    action = TouchAction(self.driver)
    sleep(1)
    start_x = window_size["width"] * 0.5
    start_y = window_size["height"]
    end_x = window_size["width"] * 0.5
    end_y = window_size["height"] * 0.5
    action.press(el, start_x, start_y).wait(100).move_to(el, end_x, end_y).release().perform()
    sleep(1)