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">
Can you do it manually?
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.
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);
@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);
opened 05:11PM - 22 Feb 17 UTC
closed 10:14PM - 13 Apr 17 UTC
## The problem
Please refer to issue https://github.com/appium/java-client/is… sues/580
1. I've an element in form of row ( XCUIElementTypeTable[1]/XCUIElementTypeCell[1] ) on which I need to swipe partial left
2. This will unhide button on right side of the row ( XCUIElementTypeTable[1]/XCUIElementTypeCell[1]/XCUIElementTypeButton[1] )
3. I have tried all options possible but couldn't get this working
4. It always results in normal swipe and next screen gets loaded
5. The behaviour is similar to Mail app in iOS.
6. I think chaining of events are not happening properly in this case.
Instead of waiting for next chain event Press -> MoveTo -> Release -> Perform
## Environment
- java client build version or git revision if you use some shapshot: 5.0.0-BETA3
- Appium server version or git revision if you use some shapshot: 1.6.4. beta
- Desktop OS/version used to run Appium if necessary: Mac 10.11.6
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: v7.2.1
- Mobile platform/version under test: 10.2
- Real device or emulator/simulator: iOS Simulator
## Details
Already mentioned under problem statement.
## Link to Appium logs
https://gist.github.com/vikramvi/220ba19708a8f1ec0bbc8d906072f209
## Code To Reproduce Issue [ Good To Have ]
I tried techniques mentioned in
https://discuss.appium.io/t/left-or-right-swipe-not-working-in-appium-for-android-app/14515
https://discuss.appium.io/t/partial-swipe-left-on-ios-simulator-10-x-not-working/14948
I didn't yet find any open source project which has similar control. Please let me know if you know any so that I can share the detailed code.
did you try to invoke “mobile: swipe” instead of using TouchAction?
1 Like