Partial Swipe left on iOS Simulator 10.X not working

Hi All,

I need to do partial swipe left on an element to make button visible in right side of that element. I tried below 3 approaches but none of them is working.

Any ideas why ?

TouchAction action1 = new TouchAction(driver).press(250 , 147).waitAction(-200).moveTo(147, 200).release();
action1.perform();

            	/*WebElement rowToSlide = AppiumController.instance.driver.findElement(By.xpath("//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]//XCUIElementTypeTable[1]/XCUIElementTypeCell[1]"));
            	               
            	TouchAction swipe = new TouchAction(driver).press(rowToSlide, 250 , 147)
                     .waitAction(-200).moveTo(rowToSlide, 200, 147).release();
      
                     swipe.perform();*/
      
    	    
            	/*Dimension size = rowToSlide.getSize();
            	
            	TouchAction swipe = new TouchAction(driver).press(rowToSlide, size.width / 2 + 100 , size.height / 2).waitAction(2000)
            	            .moveTo(rowToSlide, 100, size.height / 2).release().perform();
            	        //swipe.perform();

*/
// Point location = rowToSlide.getLocation();
//Point center = ((MobileElement) rowToSlide).getCenter();

            	/*WebElement element = AppiumController.instance.driver.findElement(By.xpath("//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]//XCUIElementTypeTable[1]/XCUIElementTypeCell[1]"));
            	Integer x_coordinate = element.getLocation().x;
            	Integer y_coordinate = element.getLocation().y;
            	Integer height = element.getSize().height;
            	Integer width  = element.getSize().width;
            	
            	TouchAction action = new TouchAction(driver);
            	action.press(element).waitAction(1000).moveTo(250, 0).release().perform();*/<img src="/uploads/default/original/2X/5/5f95277c4892449540c3e54cd982d6af70f26f15.png" width="321" height="61"><img src="/uploads/default/original/2X/3/3c050bd537472f82e627896864931c6c0bd235e3.png" width="321" height="61">
  1. Can you do it manually?
  2. Are you sure that you need waitAction at all, especially with values like 1000-2000? For me, with value more than 500 it pressing so long, that some magnifying glass is appearing. Usually, this method is used for sequences of gestures.
  3. Try just this:

new TouchAction(driver).press(rowToSlide).moveTo(-100, 0).release().perform();


-100 - means moving element left on the X axis. In your 3d example you have 250, which should cause moving right.

@rockchild thanks for reply but your solution didn’t work.

Manually I can do partial swipe to left side and view button on right side.

With your code, it is resulting in tapping on row and not doing partial swipe to left side.

I’m completely clueless after spending whole day to fix this.

Any thoughts what may be going wrong ?

@rockchild do you think I need ask developer to do something about this ?

I’m not sure why press method is resulting in tap on the row which opens another view in the app.

I can do swipe both on simulator and real device without any issue, it works fine.

Or this is bug in java client or appium server ?

Have you tried the new(er) Appium 1.6.4 beta? One of the new items says…

Add mobile: swipe execute method

@Brian_Watson below is the appium log from execution with ( 1.6.4. beta + 5.0.0-BETA3 )

XCUIElementTypeTable[1]/XCUIElementTypeCell[1] - this is row on which I need to do partial swipe left action

XCUIElementTypeTable[1]/XCUIElementTypeCell[1]/XCUIElementTypeButton[1] - this button gets shown on right side

any thoughts what may be wrong ?

    [debug] [JSONWP Proxy] Proxying [GET /element/13F33BC7-2CF7-43D3-9693-C30221B13C50/rect] to [GET http://localhost:8100/session/71470ACA-5975-4621-AA73-B40034ABD75D/element/13F33BC7-2CF7-43D3-9693-C30221B13C50/rect] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\n  \"value\" : {\n    \"y\" : 120,\n    \"x\" : 0,\n    \"width\" : 320,\n    \"height\" : 54\n  },\n  \"sessionId\" : \"71470ACA-5975-4621-AA73-B40034ABD75D\",\n  \"status\" : 0\n}"
[debug] [MJSONWP] Responding to client with driver.getSize() result: {"width":320,"height":54}
[HTTP] <-- GET /wd/hub/session/fe33bdde-d6ce-430f-b29c-117c78483519/element/13F33BC7-2CF7-43D3-9693-C30221B13C50/size 200 127 ms - 97 
[HTTP] --> POST /wd/hub/session/fe33bdde-d6ce-430f-b29c-117c78483519/touch/perform {"actions":[{"action":"press","options":{"element":"13F33BC7-2CF7-43D3-9693-C30221B13C50"}},{"action":"moveTo","options":{"x":-100,"y":0}},{"action":"release","options":{}}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"element":"13F33BC7-2CF7-43D3-9693-C30221B13C50"}},{"action":"moveTo","options":{"x":-100,"y":0}},{"action":"release","options":{}}],"fe33bdde-d6ce-430f-b29c-117c78483519"]
[debug] [XCUITest] Executing command 'performTouch'
[debug] [XCUITest] Received the following touch action: press-moveTo-release
[debug] [JSONWP Proxy] Proxying [GET /element/13F33BC7-2CF7-43D3-9693-C30221B13C50/rect] to [GET http://localhost:8100/session/71470ACA-5975-4621-AA73-B40034ABD75D/element/13F33BC7-2CF7-43D3-9693-C30221B13C50/rect] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\n  \"value\" : {\n    \"y\" : 120,\n    \"x\" : 0,\n    \"width\" : 320,\n    \"height\" : 54\n  },\n  \"sessionId\" : \"71470ACA-5975-4621-AA73-B40034ABD75D\",\n  \"status\" : 0\n}"
[debug] [JSONWP Proxy] Proxying [POST /wda/element/0/dragfromtoforduration] to [POST http://localhost:8100/session/71470ACA-5975-4621-AA73-B40034ABD75D/wda/element/0/dragfromtoforduration] with body: {"fromX":160,"fromY":147,"toX":60,"toY":147,"duration":0}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{},"sessionId":"71470ACA-5975-4621-AA73-B40034ABD75D","status":0}
[debug] [MJSONWP] Responding to client with driver.performTouch() result: {}

@Brian_Watson @rockchild

I’ve opened issue for this https://github.com/appium/java-client/issues/580

If you know any open source app with similar behavior please share, it will be useful to debug to the team.

Are you trying the AppiumDriver swipe() command?

appiumDriver.swipe(startx, starty, endx, endy, duration);

@Brian_Watson https://appium.github.io/java-client/io/appium/java_client/ios/IOSDriver.html#swipe-int-int-int-int-int-

method is deprecated, expected way of doing swipe is using chain of methods.

@rockchild @Brian_Watson as per latest appium-xcuitest-driver, I tried using mobile:swipe but no success with that as well.

Have you tried below in your project

JavascriptExecutor js = (JavascriptExecutor) driver; 
HashMap<String, String> swipeObject = new HashMap<String, String>(); 
swipeObject.put("direction", "left"); 
swipeObject.put("startX", "250"); 
swipeObject.put("startY", "147"); 
swipeObject.put("endX", "200"); 
swipeObject.put("endY", "147"); 
swipeObject.put("duration", "1.8"); 
js.executeScript("mobile: swipe", swipeObject);

did you try to invoke “mobile: swipe” instead of using TouchAction?

1 Like