Im trying to perform tap action using Appium TouchActions class, but it throws exceptions. Please provide your solution.
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.interactions.touch.TouchActions;
===========================================================
WebDriver driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities());
Thread.sleep(5000);
String title = driver.findElement(By.id("app_title")).getText();
System.out.println("TITLE: " + title);
WebElement ele = driver.findElement(By.id("bt1"));
TouchActions touch = new TouchActions(driver);
touch.singleTap(ele);
touch.perform();
Output and Exception:
Aug 02, 2018 6:51:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
TITLE: TestApp
java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
at org.openqa.selenium.interactions.touch.TouchActions.<init>(TouchActions.java:38)
at scratchpad.MobileAutomation.main(MobileAutomation.java:23)
Process finished with exit code 0
Version Used: selenium-java: 3.11.0 java-client(io.appium): 5.0.4
Let me know, if you want any other information. Also give me suggestion best way to perform Mobile operation such as swipe(all direction), tap, double tap, long press, etc. Thanks in advance.