Tapping on the screen by using coordinates


I was reading lots of articals on appium and some sayed we can tell appium server to tap on a specific location by giving the coordinates.(X and Y).
But i tried with so many ways but it didnt works for me.
Im using appium with c#.
Is there any one who has done the same thing.?
If so please share ur code with the community.:slight_smile:


Something similar to

TouchAction a2 = new TouchAction();
a2.Tap (100, 100).Perform();


See this is my output when i try that code.

:frowning: :frowning:
:frowning: :frowning:

Test Name: touchcordinates
Test FullName: AppiumDTZ.Test_ServiceRequest.touchcordinates
Test Source: d:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\Test_ServiceRequest.cs : line 315
Test Outcome: Failed
Test Duration: 0:00:18.4543878

Result Message:
Test method AppiumDTZ.Test_ServiceRequest.touchcordinates threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Result StackTrace:
at OpenQA.Selenium.Appium.MultiTouch.TouchAction.Perform()
at AppiumDTZ.ElementsServiceRequest.touchcordinates() in d:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\ElementsServiceRequest.cs:line 532
at AppiumDTZ.Test_ServiceRequest.touchcordinates() in d:\QA automation\appium\AppiumTFS\DTZAppium\AppiumDTZ\AppiumDTZ\Test_ServiceRequest.cs:line 317


It’s work for my after initialization with driver:

ITouchAction swipe = new TouchAction(driver);

where driver is instance of



Yes, off course :slight_smile: I wrote my code from memory, sorry. The code wont even compile unless you provide the driver!


In the latest Appium (1.4.13) code compiles without any error.


I’m using Java. And when I replied 3 days ago, I didn’t check the original post about using C# :relaxed:


I am getting below error on using tap(x,y):
Command returned error:java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission

info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:13,“value”:“Injecting to another application requires INJECT_EVENTS permission”}
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:“An unknown server-side error occurred while processing the command.”,“origValue”:“Injecting to another application requires INJECT_EVENTS permission”


Can you tell how to do it in Java?
With full example of code

TouchAction touchAction=new TouchAction(driver);
touchAction.tap(xPoint, yPoint).perform();


Telmo, thx for fast answer. But I still can’t understand how to put it in my code.

My code:

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;

public class GameTest {
public static void main(String[] args) throws MalformedURLException, InterruptedException {

    DesiredCapabilities caps = new DesiredCapabilities();

    AndroidDriver driver = new AndroidDriver(new URL(""), caps);


    driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Apps\")").click();
    driver.findElementByAndroidUIAutomator("new UiSelector().text(\"FunnyFarm\")").click();

So, after I opened this app (its a game). I need to tap “start” button.
I just need to add
TouchAction touchAction=new TouchAction(driver);
touchAction.tap(xPoint, yPoint).perform();
and instead xPoint and yPoint trying to guess what are coordinates of this button? Or how it should works


Well… first you do not need to open the app “manually” by touching on its icon. You can use capabilities appActivity and appPackage to indicate witch is the package/activity you want to launch.

Now, about the “start” button. Have you opened uiautomatorviewer to see if you can tap on the id, text, content description, etc.? If so, then you can use your findElementByAndroidUIAutomator or findElementByID or any other strategy to tap on it.


Hi, the search key on the android key is not clickable, the enter key of the app was working fine few days ago bt it has stopped working now after some changes made by the developer in the app…I am only left with option of clicking on the coordinates of search(magnifier) on keyboard.Can you tell me how can i get the coordinates of that…Thanks