Swipe from bottom to top

I have this code and I am trying to swipe from bottom to top. This code swipes from left to right.
My issue is I don’t know who to find the location where the swipe starts…

And I need to swipe from bottom point to top…

Can anyone share how I can get this done?

Thank you!

Take the list of visible elements
take position of first visible element
take position of last visible element
swipe from last visible element to first visible element
continue swiping until the list of all visible elements is not same

Hope it would work.

Thanks but sorry… I am new to java and appium…

It sounds like you have your X and Y coordinates reversed for the swipe. You’ll have to find the location in the code of where you calculate the coordinates and verify they are being passed to the swipe method properly

  1. How to swipe
    swipe like (50,100) to (50,500) swipe for 400 units in increasing y coordinate direction
    driver.swipe(50,100,50,500,1000); // swipe from botton to top as y coordinate is increasing and x coordinate is constant, HERE 1000 last param is swipe duration.

  2. To get location, it can be taken based on any WebElement e.g.

int startX= driver.findElement(By.id(“Element_AT_NEAR_TO_BOTTOM_OF_SCREEN”)).getLocation().getX();
int startY= driver.findElement(By.id(“Element_AT_NEAR_TO_BOTTOM_OF_SCREEN”)).getLocation().getY();
int endX= driver.findElement(By.id(“Element_AT_NEAR_TO_TOP_OF_SCREEN”)).getLocation().getX();
int endY= driver.findElement(By.id(“Element_AT_NEAR_TO_TOP_OF_SCREEN”)).getLocation().getY();
int swipeDuration = 1000;
driver.swipe(startX,startY,endX,endY,swipeDuration); // swipe upwards

driver.swipe(endX,endY,startX,startY,swipeDuration); // swipe downwards as coordinates are reversed

Here any locator strategy can be used to find webelement, then we can get location in similar way …

Thank you! It worked!!! I appreciate it again.