Unable to swipe using coordinates

Hello,

I have a native android app page and it has 4 Linear Layouts. Three of them are visible and 1 is hidden at the bottom. I need to scroll the screen little bit to make the 4th Layout visible. I am using below code:
int startx = screenWidth/2;
int endx = screenWidth/2;
int starty = screenHeight*1/4;
int endy = screenHeight/2;
driver.swipe(startx, starty, endx, endy, 5000);

But it’s doing nothing and I am getting no error in the logs.

Note: The test case is to get the count of all the relative layouts (which are child of Linear Layouts). In case there is any other workaround to accomplish the result please feel free to help.

Thanks in Advance.

Is your 4th linear layout below the other layouts, or is it above the other layouts? The way you have your starty and endy set up will cause Appium to simulate a finger swiping down on the screen (AKA scrolling up). If your view is already at the top, then swiping down should rightfully do nothing.

Note that the positive y-axis points down towards the bottom of the screen on Android systems. The positive x-axis points to the right edge of the screen. If you know about the right-hand rule for coordinate systems, then the z-axis points into the screen.

int starty = screenHeight*1/4;
int endy = screenHeight/2;

= you swiping from top to bottom. but said that need element on bottom to appear. you need reverse order of start and end.

1 Like

4th layer is hidden at the bottom of the screen.
@Aleksei
I have reversed the order of start and end of y co-ordinates as you suggested but it is still doing nothing. on the screen. Here are the logs:
info: <-- GET /wd/hub/session/057e1edb-1dc6-4338-bca8-05e4f708a6ab/window/current/size 200 6.515 ms - 100 {“status”:0,“value”:{“height”:1794,“width”:1080},“sessionId”:“057e1edb-1dc6-4338-bca8-05e4f708a6ab”}
info: --> POST /wd/hub/session/057e1edb-1dc6-4338-bca8-05e4f708a6ab/touch/perform {“actions”:[{“action”:“press”,“options”:{“x”:540,“y”:897}},{“action”:“wait”,“options”:{“ms”:5000}},{“action”:“moveTo”,“options”:{“x”:540,“y”:1345}},{“action”:“release”,“options”:{}}]}
info: [debug] Pushing command to appium work queue: [“swipe”,{“startX”:540,“startY”:897,“endX”:540,“endY”:1345,“steps”:140}]
info: [debug] [BO
OTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“swipe”,“params”:{“startX”:540,“startY”:897,“endX”:540,“endY”:1345,“steps”:140}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: swipe
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1794]
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1794]
info: [debug] [BOOTSTRAP] [debug] Swiping from [x=540.0, y=897.0] to [x=540.0, y=1345.0] with steps: 140

Enable show touches on phone. Repeat test. Check where the swipe touches happens. Try same manually. Correct touch start end if needed.

It’s working now.
Problem was that even when 3 layers are showing up, the 4th one is not loading at the same time. So there was nothing to swipe to.
Added a delay and it fixed the issue and Here are the co-ordinates that I used to make it happen:
int starty = screenHeight*3/4;
int endy = screenHeight/2;

Thanks for your help guys.