TouchActions for Mobile android devices

Hi,

I’ve been trying to use TouchAction on an Android device and come across some issues. The element locations seems to have no effect or the actions just fail, here is my code:

// my driver extends AndroidDriver and implements HasTouchScreen
driver.context("WEBVIEW_1");
driver.navigate().to("http://espn.com");
WebElement uploadBtn = driver.findElementById("nav-drop-search");
	
driver.context("NATIVE_APP");
TouchAction btnAction = new TouchAction(driver).moveTo(300, 400);
btnAction.perform(); 
//An unknown server-side error occurred while processing the command
	
btnAction = new TouchAction(driver).longPress(uploadBtn);
btnAction.perform(); 
//long press in the middle of the screen, regardless the element position
	
btnAction = new TouchAction(driver).tap(uploadBtn);
btnAction.perform(); 
//An unknown server-side error occurred while processing the command
	
btnAction = new TouchAction(driver).moveTo(uploadBtn);
btnAction.perform(); 
//An unknown server-side error occurred while processing the command
	
btnAction = new TouchAction(driver).press(uploadBtn);
btnAction.perform(); 
//press in the middle of the screen, regardless the element position

Are these known issues? Or am I doing something wrong?

Thanks

you can use this:

public void tapScreen(double xCoordinate, double yCoordinate) {
JavascriptExecutor js = (JavascriptExecutor) devicedriver;
HashMap<String, Double> tapObject = new HashMap<String, Double>();
tapObject.put(“x”, xCoordinate);
tapObject.put(“y”, yCoordinate);
js.executeScript(“mobile: tap”, tapObject);
}

Thanks for the reply…
But, I want to use the TouchAction with elements. Is there a way to do this?