Motion Gestures Swipe skips over the area I want to reach

Motion Gestures Swipe skips over the area I want to reach

public static void swipeUp60(AppiumDriver appiumdriver) {
((JavascriptExecutor) appiumdriver).executeScript(“mobile: swipeGesture”, ImmutableMap.of(
“left”, 400, “top”, 900, “width”, 400, “height”, 900,
“direction”, “up”,
“percent”, 0.60
));
}

	    public static void swipeDown40(AppiumDriver appiumdriver) {
	    	((JavascriptExecutor) appiumdriver).executeScript("mobile: swipeGesture", ImmutableMap.of(
	    		    "left", 400, "top", 900, "width", 400, "height", 900,
	    		    "direction", "down",
	    		    "percent", 0.40
	    		));
	    }



			List <WebElement> propertypiclist = (List<WebElement>) driver.findElements(propertypic);
			WebElement property1pic = propertypiclist.get(0);
			property1pic.click();
			Thread.sleep(4000);

			MiscMethods.swipeUp60(driver);
	        Thread.sleep(4000);
	        
	        MiscMethods.swipeDown40(driver);
	        Thread.sleep(4000);
	        
	        WebElement listingDetailsElement = wait.until(ExpectedConditions.elementToBeClickable(listingDetails));
	        listingDetailsElement.click();

Page starts like this

I want to go to middle next page

But the swipe takes me to the end of the page here

try:

  1. reduce swipe speed
  2. switch to scrollGesture -> https://appium.io/docs/en/writing-running-appium/android/android-mobile-gestures/#mobile-scrollgesture
  3. use anything from -> http://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/

Thanks. Scroll and speed helped fixed the problem.

public static void scrollUp(AppiumDriver appiumdriver) {
((JavascriptExecutor) appiumdriver).executeScript(“mobile: scrollGesture”, ImmutableMap.of(
“left”, 100, “top”, 100, “width”, 400, “height”, 400,
“direction”, “up”,
“percent”, 8.0,
“speed”, 10000
));
}

    public static void scrollDown(AppiumDriver appiumdriver) {
    	 ((JavascriptExecutor) appiumdriver).executeScript("mobile: scrollGesture", ImmutableMap.of(
    		    "left", 100, "top", 100, "width", 400, "height", 400,
    		    "direction", "down",
    		    "percent", 5.0,
    		    "speed", 10000
    		));
    }