[ios device] Can not swipe on ios device

I’m newbie in ios appium automation testing. I try to swipe down my device ( real device and simulator) but i have error:

Swipe from x: 256.0 y: 422.4 to x: 256.0 y: 168.0
Have error when swipe app: org.openqa.selenium.WebDriverException: point is not within the bounds of the screen (WARNING: The server did not provide any stacktrace information)

And this is my code for iphone 4s:

static Integer getScreenWidth(IOSDriver driver){
return driver.manage().window().getSize().getWidth();
}

static Integer getScreenHeight(IOSDriver driver){
    return driver.manage().window().getSize().getHeight();
}

public static void swipeUp(IOSDriver driver, Double percentStartX,
                           Double percentStartY, Double percentEndX, Double percentEndY, int duration){

    try {
        Double startX = percentStartX * getScreenWidth(driver);
        Double startY = percentStartY * getScreenHeight(driver);
        Double endX = percentEndX * getScreenWidth(driver);
        Double endY = percentEndY * getScreenHeight(driver);

        Log.info("Swipe from x: " + String.valueOf(startX) + " y: " + String.valueOf(startY) +
                " to x: " + String.valueOf(endX) + " y: " + String.valueOf(endY));

        driver.swipe(startX.intValue(), startY.intValue(), endX.intValue(), endY.intValue(), duration);

// TouchAction action = new TouchAction(driver).longPress(startX.intValue(), startY.intValue(), duration).
// moveTo(endX.intValue(), endY.intValue()).release();
// action.perform();

    }catch (Exception ex){
        Log.error("Have error when swipe app: " + ex);
    }

}

I try to use TouchAtion but still have same error.

Please hep me! Oh, i do not how write code separately, it’s same style with normal text >.<

Thanks so much!

thanks for writing your appium version and java client used.

remember in 1.5.x appium swipe endX/endY are relative! but in 1.4.x is absolute.

1 Like

Thanks for your help.

appium version: 1.5.2

java -version
java version “1.8.0_73”
Java™ SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot™ 64-Bit Server VM (build 25.73-b02, mixed mode)

so how you swiping? write example. what values you put to swipe. what screen resolution you have. what apppium server writing in log.

I want to swipe down iphone 4s screen, screen size: 320x480. Firstly, i get screen width and hight:

static Integer getScreenWidth(IOSDriver driver){
return driver.manage().window().getSize().getWidth();
}

static Integer getScreenHeight(IOSDriver driver){
return driver.manage().window().getSize().getHeight();
}

And then i set percent of point that i want to swipe. I want to swipe from point (256, 422.4) to point (256.0 y: 168.0) so that screen device will down to see some another element in page.

And this is appium log:

[debug] [iOS] Executing iOS command ‘click’
[debug] [UIAuto] Sending command to instruments: au.tapById(‘153’)
[debug] [Instruments] [INST] 2016-05-27 03:09:07 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:07 +0000 Debug: Running system command #236: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:[{“ELEMENT”:“153”}]}…
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: Got new command 236 from instruments: au.tapById(‘153’)
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: evaluating au.tapById(‘153’)
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: target.frontMostApp().elements()[0].elements()[11].tap()
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: responding with:
[debug] [UIAuto] Socket data received (25 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:""}
[MJSONWP] Responding to client with driver.click() result: null
[HTTP] <-- POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/element/153/click 200 1185 ms - 76
[debug] [Instruments] [INST] 2016-05-27 03:09:08 +0000 Debug: Running system command #237: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:""}…
[HTTP] --> GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size
[MJSONWP] Calling AppiumDriver.getWindowSize() with args: [“current”,“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘getWindowSize’
[debug] [UIAuto] Sending command to instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:09 +0000 Debug: Got new command 237 from instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:09 +0000 Debug: evaluating au.getWindowSize()
[debug] [UIAuto] Socket data received (49 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:{“width”:320,“height”:480}}
[MJSONWP] Responding to client with driver.getWindowSize() result: {“width”:320,“height”:480}
[HTTP] <-- GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size 200 1034 ms - 98
[debug] [Instruments] [INST] 2016-05-27 03:09:09 +0000 Debug: evaluation finished
[HTTP] --> GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size
[MJSONWP] Calling AppiumDriver.getWindowSize() with args: [“current”,“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘getWindowSize’
[debug] [UIAuto] Sending command to instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:09 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:09 +0000 Debug: Running system command #238: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:{“width”:320,“height”:480}}…
[debug] [Instruments] [INST] 2016-05-27 03:09:11 +0000 Debug: Got new command 238 from instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:11 +0000 Debug: evaluating au.getWindowSize()
[debug] [UIAuto] Socket data received (49 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:{“width”:320,“height”:480}}
[MJSONWP] Responding to client with driver.getWindowSize() result: {“width”:320,“height”:480}
[HTTP] <-- GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size 200 1067 ms - 98
[HTTP] --> GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size
[MJSONWP] Calling AppiumDriver.getWindowSize() with args: [“current”,“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘getWindowSize’
[debug] [UIAuto] Sending command to instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:11 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-05-27 03:09:11 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:11 +0000 Debug: Running system command #239: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:{“width”:320,“height”:480}}…
[debug] [Instruments] [INST] 2016-05-27 03:09:12 +0000 Debug: Got new command 239 from instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:12 +0000 Debug: evaluating au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:12 +0000 Debug: evaluation finished
[debug] [UIAuto] Socket data received (49 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:{“width”:320,“height”:480}}
[MJSONWP] Responding to client with driver.getWindowSize() result: {“width”:320,“height”:480}
[HTTP] <-- GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size 200 1015 ms - 98
[HTTP] --> GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size
[MJSONWP] Calling AppiumDriver.getWindowSize() with args: [“current”,“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘getWindowSize’
[debug] [UIAuto] Sending command to instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:12 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:12 +0000 Debug: Running system command #240: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:{“width”:320,“height”:480}}…
[debug] [Instruments] [INST] 2016-05-27 03:09:13 +0000 Debug: Got new command 240 from instruments: au.getWindowSize()
[debug] [Instruments] [INST] 2016-05-27 03:09:13 +0000 Debug: evaluating au.getWindowSize()
[debug] [UIAuto] Socket data received (49 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:0,“value”:{“width”:320,“height”:480}}
[MJSONWP] Responding to client with driver.getWindowSize() result: {“width”:320,“height”:480}
[HTTP] <-- GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/window/current/size 200 911 ms - 98
[HTTP] --> POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/touch/perform
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“press”,“options”:{“x”:256,“y”:422}},{“action”:“wait”,“options”:{“ms”:3000}},{“action”:“moveTo”,“options”:{“x”:256,“y”:168}},{“action”:…
[debug] [iOS] Executing iOS command ‘performTouch’
[debug] [UIAuto] Sending command to instruments: target.touch([{“touch”:[{“x”:256,“y”:422}],“time”:0.2},{“touch”:[{“x”:256,“y”:422}],“time”:3.2},{“touch”:[{“x”:512,“y”:590}],“time”:3.4000000000000004}])
[debug] [Instruments] [INST] 2016-05-27 03:09:13 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-05-27 03:09:13 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:13 +0000 Debug: Running system command #241: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:0,“value”:{“width”:320,“height”:480}}…
[debug] [Instruments] [INST] 2016-05-27 03:09:14 +0000 Debug: Got new command 241 from instruments: target.touch([{“touch”:[{“x”:256,“y”:422}],“time”:0.2},{“touch”:[{“x”:256,“y”:422}],“time”:3.2},{“touch”:[{“x”:512,“y”:590}],“time”:3.4000000000000004}])
[debug] [Instruments] [INST] 2016-05-27 03:09:14 +0000 Debug: evaluating target.touch([{“touch”:[{“x”:256,“y”:422}],“time”:0.2},{“touch”:[{“x”:256,“y”:422}],“time”:3.2},{“touch”:[{“x”:512,“y”:590}],“time”:3.4000000000000004}])
[debug] [Instruments] [INST] 2016-05-27 03:09:14 +0000 Debug: target.touch(__NSCFArray)
[debug] [Instruments] [INST] 2016-05-27 03:09:17 +0000 Debug: point is not within the bounds of the screen
[debug] [Instruments] [INST] 2016-05-27 03:09:17 +0000 Error: VerboseError: point is not within the bounds of the screen
[debug] [UIAuto] Socket data received (70 bytes)
[debug] [UIAuto] Got result from instruments: {“status”:17,“value”:“point is not within the bounds of the screen”}
[HTTP] <-- POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/touch/perform 500 4543 ms - 131
[debug] [Instruments] [INST] 2016-05-27 03:09:17 +0000 Error: Error during eval: touch@[native code]
eval code
eval@[native code]
startProcessing@file:///usr/local/lib/node_modules/appium/A86032DC-6610-48DD-B83B-3D1BD1541D5E/bootstrap-5e34876f27a599d3.js:2793:30
bootstrap@file:///usr/local/lib/node_modules/appium/A86032DC-6610-48DD-B83B-3D1BD1541D5E/bootstrap-5e34876f27a599d3.js:2861:31
global code@file:///usr/local/lib/node_modules/appium/A86032DC-6610-48DD-B83B-3D1BD1541D5E/bootstrap-5e34876f27a599d3.js:2870:10
[debug] [Instruments] [INST] 2016-05-27 03:09:17 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-05-27 03:09:17 +0000 Debug: Running system command #242: /usr/local/Cellar/node/5.9.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/fy/14y8wfl53qjfx_l1vnm3fc1r0000gn/T/instruments_sock 2,{“status”:17,“value”:“point is not within the bounds of the screen”}…
[HTTP] --> POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/timeouts
[MJSONWP] Calling AppiumDriver.timeouts() with args: [“implicit”,0,“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘timeouts’
[MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/timeouts 200 2 ms - 76
[HTTP] --> GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/context
[MJSONWP] Calling AppiumDriver.getCurrentContext() with args: [“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘getCurrentContext’
[MJSONWP] Responding to client with driver.getCurrentContext() result: “NATIVE_APP”
[HTTP] <-- GET /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/context 200 3 ms - 84
[HTTP] --> POST /wd/hub/session/07c05101-ef89-464f-98cd-6882ab43aa55/elements
[MJSONWP] Calling AppiumDriver.findElements() with args: [“xpath”,"//UIAApplication[1]/UIAWindow[1]/UIATabBar[1]/UIAButton[4]",“07c05101-ef89-464f-98cd-6882ab43aa55”]
[debug] [iOS] Executing iOS command ‘findElements’

i investigated that when executing driver.swipe, app have some error such tabbing point ( 288, 440) but app tab other point and can not click back button on navigation bar.

Any suggest for me?

what version of iOS / Xcode? mobile swipe is completely broken in iOS < 9 Xcode < 7 in my experience. You’ll have to use iOS 9.X for it to work.

Long standing issue: iOS 8 swipe / scrollTo

1 Like

but i can not run my test on ios 9.X >.<

I have the same problem. When I update java-client to 4.0.0, problem has been fixed

1 Like

@CrashTestDummy: you have same prolem that can not swipe on ion 8.X or can not run appium test on ios 9.X ?

can not swipe, after update appium to 1.5.2. On older version appium (1.4) swipe work fine

1 Like

oh great, i will try with appium 1.4 :slight_smile:

Had the same problem with appium version 1.5.3 and ios ,
for me the solution in python was:
wd.swipe(start point X,start point Y,end point X,end point Y)
for example: wd.swipe(676,1598,0,-930)

2 Likes

try
JavascriptExecutor js = (JavascriptExecutor) driver;
Map<String, Object> params = new HashMap<>();
params.put(“direction”, “down”);
params.put(“element”, ((RemoteWebElement) element).getId());
js.executeScript(“mobile: swipe”, params);

1 Like