Android - Java - Tap at coordinates with Selendroid on native app

I am trying to perform a tap at coordinates x, y on a native Android app, on a device that is lower than API 17.

Here’s what I am trying:

public void selendroidTapAtCoordinate(final int x, final int y, final int secs) throws Exception {
    TouchActions actions = new TouchActions(driver);
    actions.down(x, y);
    actions.up(x, y);

The error I get:

java.lang.ClassCastException: io.appium.java_client.AppiumDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen

This is a native app and all I want to do is tap the screen at certain coordintates. Can anyone help with this?

I am using latest version of appium (1.2.3) and java client 1.7.0.


Did you tried driver.tap(arg0, arg1, arg2, arg3);

tap on Selendroid will result it:
org.openqa.selenium.UnsupportedCommandException: Build info: version: ‘2.42.2’

That is expected, i think u r using android in selendroid mode. so it wont support “TouchAction” methods. U need to go with pure selendroid implementations.

Did you ever figure out a workaround for this? I am having this exact issue. Seems like we can’t use the selendroid gesture implementation because the java client cannot be cast to touch actions

I found a good solution on the old boards thanks to user “Mario”:!searchin/appium-discuss/selendroid$20touch/appium-discuss/IXKgTji4kjU/tTjPV7MT3JIJ

Subclass the AndroidDriver to implement HasTouchScreen, and use this instead:

public class SelendroidDriver extends AndroidDriver implements HasTouchScreen {
	public RemoteTouchScreen touch;
	public SelendroidDriver(URL remoteAddress,
			Capabilities desiredCapabilities) {
		super(remoteAddress, desiredCapabilities);
		touch = new RemoteTouchScreen(getExecuteMethod());

	public TouchScreen getTouch() {
		return touch;
1 Like

HI Antony,
What is the 4 arguments in the tap method…

Never tried this before but my best assumption is
driver.tap(fingers, x, y, duration);

@vicwomg Thank you , you are a life saver.

Thank you @vicwomg,

For pointing towards the solution. I am automating a hybrid app, Where we need to use tap on elements. With this solution I am able to use TouchAction class with selenium Webdriver and implement tap feature.