Android Swipe isn't working - v 1.19

package tests;

import java.time.Duration;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.testng.annotations.Test;

import com.google.common.collect.ImmutableMap;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.PointOption;

public class Camera extends baseClass {

@Test
public void swipe(int startX, int startY, int endX, int endY, int msDuration) {
    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(PointOption.point(1000, 1000))
            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(2000)))
            .moveTo(PointOption.point(350, 1000))
            .release();

    touchAction.perform();
}

enable in developer menu of phone to show touches and path. check where your swipe actually happens. double check that you can manually swipe using SAME coordinates manually.

@Aleksei , I have changed code as below:

Still having an issue.
It was working fine without using public void method , and red underlined on driver

Still get an error after remove all complaints

your “driver” variable is NULL

1 Like