WaitAction doesn't work with the specified duration

Hi everyone,

I am new at test automation and trying to figure out things. Below an example of a code that I’ve written. Even if I specify the duration of press action as 3 seconds, it is hold like almost 10 seconds.
How can I solve this? The examples on the internet has the exact same code with mine.

Thanks in advance.

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;
import org.junit.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;

import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;

public class Press_LongPress{

AndroidDriver androidDriver;


@Test
public void testAppium() throws MalformedURLException  {


    DesiredCapabilities myCapabilites = new DesiredCapabilities();

    myCapabilites.setCapability("platformName", "Android");
    myCapabilites.setCapability("platformVersion", "7.0");
    myCapabilites.setCapability("deviceName", "Nexus S API 24");
    myCapabilites.setCapability("automationName", "UiAutomator2");
    myCapabilites.setCapability("appPackage", "com.android.dialer");
    myCapabilites.setCapability("appActivity","com.android.dialer.DialtactsActivity");
    myCapabilites.setCapability("fullReset", "false");


    androidDriver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub/"), myCapabilites);
    TouchAction action = new TouchAction(androidDriver);

    WebElement button = androidDriver.findElementById("com.android.dialer:id/voice_search_button");

    Point location = button.getLocation();
    Dimension size = button.getSize();
    int x = location.getX() + (size.getWidth() / 2);
    int y = location.getY() + (size.getHeight() / 2);

    action.press(PointOption.point(x,y)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(4))).release().perform();


}


@AfterTest

public void afterTest(){

    androidDriver.quit();
}

}

It might be that your application under test is not idling, so the client waits until idle timeout expires. You could try to adjust waitForIdleTimeout setting and/or disable the trackScrollEvents cap.

Any update on this?

I try to run a series press, wait, moveto, wait, moveto, release, perform actions.
the wait time is about 50-100ms each.

It runs perfect on ios. but on Android, the wait time is over 1 second for a supposed 100ms. Not sure what is the root cause.

My sample code: omit a few moveto, waitAction

TouchAction action = new TouchAction(androidDriver);
action.press(point(100,100)).waitAction(WaitOptions.waitOptions(Duration.ofMills(100))).moveTo(point(100,200)).waitAction(WaitOptions.waitOptions(Duration.ofMills(100))).moveTo(point(200,300))
.release().perform();