I need to long press a button for a few secs and release, I have the following code,
WebElement recordButton = driver.findElement(By.id("xxxxxx/record_button"));
TouchActions action = new TouchActions(driver);
action.longPress(recordButton);
action.release();
action.perform();
I get the below errors
java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
What I'm I doing wrong.
Trace:
java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
Appium v1.8.1
Dependencies used:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.internal.TouchAction;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.net.URL;
AndroidDriver<AndroidElement>
and use AndroidElement instead of WebElement. Only a suggestions, not positive it will work. Also, doesn't longPress have a duration parameter? You might also need to do a .build() before the .perform()