# Difference between click() and tap()

**URL:** <https://discuss.appium.io/t/difference-between-click-and-tap/295>\
**Category:** Tutorials/Documentation\
**Created:** [September 10, 2014, 11:02pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295 "2014-09-10T23:02:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![iandow](https://discuss.appium.io/user_avatar/discuss.appium.io/iandow/32/5321_2.png) [@iandow](https://discuss.appium.io/u/iandow)\
**Post date:** [September 10, 2014, 11:02pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/1 "2014-09-10T23:02:06Z")

</div>

If I want to tap on a certain iOS button, should I get a WebElement object from its xpath and invoke the click() method on it, or should I use driver.tap() method to tap a specific x/y coordinate?

i.e. Should I do this:

```
WebElement button = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]"));
button.click();

```

or this:

```
driver.tap(1,134,526,1);
```

---

<div class="post-metadata">

**Author:** ![Pratyush](https://discuss.appium.io/user_avatar/discuss.appium.io/pratyush/32/3236_2.png) [@Pratyush](https://discuss.appium.io/u/Pratyush)\
**Post date:** [September 11, 2014, 1:38pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/2 "2014-09-11T13:38:57Z")

</div>

According to my understanding, it is better to use driver.tap() method as it is more closely binded to the mobile scenario. tap() method belongs to AppiumDriver class while the click() method belongs to the WebDriver class.

It’s better to go for tap() method as they have extracted all mobile native gestures and pushed them to java\_client library for better implementation.

By the way, you can also use `driver.tap(int x, WebElement we, int y) `if you don’t want to go by specific x/y coordinates.

---

<div class="post-metadata">

**Author:** ![osamaa](https://discuss.appium.io/letter_avatar_proxy/v4/letter/o/dec6dc/32.png) [@osamaa](https://discuss.appium.io/u/osamaa)\
**Post date:** [September 18, 2014, 12:46pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/3 "2014-09-18T12:46:27Z")

</div>

How we can pass x/y coordinates of an element? How we can get that?  
Currently, I’m using click() function in my tests which needs only element to click with no coordinates.  
I’m new to appium and don’t know how to pass coordinates in tap() function. Please explain me with example.

Thanks.

---

<div class="post-metadata">

**Author:** ![Pratyush](https://discuss.appium.io/user_avatar/discuss.appium.io/pratyush/32/3236_2.png) [@Pratyush](https://discuss.appium.io/u/Pratyush)\
**Post date:** [September 19, 2014, 6:42am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/4 "2014-09-19T06:42:19Z")

</div>

You can get the x/y coordinates of the element through the inspector provided by appium UI tool.  
For general, the tap function is `tap(int x, WebElement we, int y)`. Here, you can pass 1 as x and y and the WebElement object. This would perform a tap on the webElement you are trying to click.

---

<div class="post-metadata">

**Author:** ![lgabrielgr](https://discuss.appium.io/user_avatar/discuss.appium.io/lgabrielgr/32/5311_2.png) [@lgabrielgr](https://discuss.appium.io/u/lgabrielgr)\
**Post date:** [September 25, 2014, 2:10pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/5 "2014-09-25T14:10:39Z")

</div>

@osamaa, using ruby client, you can get the locations by Element.location\_rel.x and Element.location\_rel.y

Java and other clients should have something similar.

---

<div class="post-metadata">

**Author:** ![iRANG\_QA](https://discuss.appium.io/letter_avatar_proxy/v4/letter/i/3e96dc/32.png) [@iRANG\_QA](https://discuss.appium.io/u/iRANG_QA)\
**Post date:** [March 18, 2015, 7:04am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/6 "2015-03-18T07:04:42Z")

</div>

Does TAP method will work when testing app using emulator? OR it support only real device?

---

<div class="post-metadata">

**Author:** ![UD](https://discuss.appium.io/letter_avatar_proxy/v4/letter/u/3be4f8/32.png) [@UD](https://discuss.appium.io/u/UD)\
**Post date:** [March 18, 2015, 8:28am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/7 "2015-03-18T08:28:20Z")

</div>

I feel Tap and Click work the same way. It works just like click in emulator.

But prefer using Click as it doesnt require any x,y coordinates. The reason being, if the object location changes, maintenance costs go up.

If you use click method, as it associates to webelement, even the element is located in different locations doesnt have any problem.

---

<div class="post-metadata">

**Author:** ![iRANG\_QA](https://discuss.appium.io/letter_avatar_proxy/v4/letter/i/3e96dc/32.png) [@iRANG\_QA](https://discuss.appium.io/u/iRANG_QA)\
**Post date:** [March 18, 2015, 8:37am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/8 "2015-03-18T08:37:40Z")

</div>

Yes I agree with you. But if we do not have any way to identify element and we have only coordinates then we have to use TAP? Because I think wan no specify coordinate with Click () method.

---

<div class="post-metadata">

**Author:** ![Telmo\_Cardoso](https://discuss.appium.io/user_avatar/discuss.appium.io/telmo_cardoso/32/1435_2.png) [@Telmo\_Cardoso](https://discuss.appium.io/u/Telmo_Cardoso)\
**Post date:** [March 18, 2015, 8:54am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/9 "2015-03-18T08:54:12Z")

</div>

tap and click sometimes suffer from the elements not being valid anymore and returning “not able to tap element”.

With this being said, I normally use tab on buttons that I’m sure are there. Whenever I get any problem with tapping on visible elements (but appium states they aren’t visible, etc.) I user TouchAction.new.press on Element. So no maintenance costs and it always presses on the spot even when tap/click does not work

---

<div class="post-metadata">

**Author:** ![AjitJ](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@AjitJ](https://discuss.appium.io/u/AjitJ)\
**Post date:** [April 28, 2015, 2:40pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/10 "2015-04-28T14:40:20Z")

</div>

How to Use Tab On Button.  
As I was trying the same but it was not possible to me…as I used Keys.TAB and “/t” in Send Keys.

Please let me know how to tab on iOS Element in Appium.  
Thanks,  
Ajit Jadhav.

---

<div class="post-metadata">

**Author:** ![kirill](https://discuss.appium.io/user_avatar/discuss.appium.io/kirill/32/1205_2.png) [@kirill](https://discuss.appium.io/u/kirill)\
**Post date:** [April 30, 2015, 3:04am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/11 "2015-04-30T03:04:17Z")

</div>

Usual click doesn’t work?

---

<div class="post-metadata">

**Author:** ![AjitJ](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@AjitJ](https://discuss.appium.io/u/AjitJ)\
**Post date:** [April 30, 2015, 6:06am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/12 "2015-04-30T06:06:29Z")

</div>

yah…its not…if Element is \Hidden and Need to Scroll…  
even its avilable in DOM.

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [August 7, 2015, 6:05pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/14 "2015-08-07T18:05:52Z")

</div>

@Ravi15, why don’t you start a new topic as this question doesn’t have much to do with this particular topic.

---

<div class="post-metadata">

**Author:** ![Eyal\_Sooliman](https://discuss.appium.io/letter_avatar_proxy/v4/letter/e/7ab992/32.png) [@Eyal\_Sooliman](https://discuss.appium.io/u/Eyal_Sooliman)\
**Post date:** [November 12, 2015, 8:21am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/15 "2015-11-12T08:21:07Z")

</div>

To find the element X and Y, you can do the following:

WebElement el = driver.findElement(“Your element”);  
Point p = ((Locatable) el).getCoordinates().onPage();  
driver.tap(1,p.getX(),p.getY(),1);

---

<div class="post-metadata">

**Author:** ![Julien\_Blanc](https://discuss.appium.io/user_avatar/discuss.appium.io/julien_blanc/32/1442_2.png) [@Julien\_Blanc](https://discuss.appium.io/u/Julien_Blanc)\
**Post date:** [November 12, 2015, 9:59am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/16 "2015-11-12T09:59:36Z")

</div>

Myself, I use a method I’ve wrote called tapOn :

```
 public static void tapOn(WebElement element){
        new TouchAction((MobileDriver) getDriver()).tap(element).perform();
    }

```

I just send him a WebElement. To get it, I use this :

```
getDriver().findElement(By.xpath(elementSelector))

```

where the elementSelector is the xPath, found with Appium finder for example.

It makes me able to first get the WebElement in the view, and then create the methods to tap on it.

---

<div class="post-metadata">

**Author:** ![rompic](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@rompic](https://discuss.appium.io/u/rompic)\
**Post date:** [November 12, 2015, 11:24am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/17 "2015-11-12T11:24:16Z")

</div>

I also experience a element cannot be tapped situation and using press is at least a step forward. Anyone knows if there’s an upcoming fix?

> <https://github.com/appium/appium/issues/2389>

---

<div class="post-metadata">

**Author:** ![ravikr42](https://discuss.appium.io/user_avatar/discuss.appium.io/ravikr42/32/1493_2.png) [@ravikr42](https://discuss.appium.io/u/ravikr42)\
**Post date:** [November 12, 2015, 12:18pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/18 "2015-11-12T12:18:16Z")

</div>

Hi @Julien_Blanc

What is getDriver() Method here.

I am using like this new TouchAction(((MobileDriver)driver).tap(arg0, arg1, arg2)), and here I am not getting tap() method which takes only one arguement, also perform() method is not coming.

Could you please explain your method in more detail.

Thanks

---

<div class="post-metadata">

**Author:** ![Julien\_Blanc](https://discuss.appium.io/user_avatar/discuss.appium.io/julien_blanc/32/1442_2.png) [@Julien\_Blanc](https://discuss.appium.io/u/Julien_Blanc)\
**Post date:** [November 12, 2015, 1:21pm UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/19 "2015-11-12T13:21:50Z")

</div>

Yes for sure.

First I’ve the method getDriver :

```
public static WebDriver getDriver(){
        return AppiumTest.driver;
    }

```

It returns the driver, to make actions afterward.

Then each screen of the app is split in two sides : first I get the elements, then I create the methods (actions).

To get the elements, I use the method findElement i’ve wrote above.  
And after, to tap on an element, I’ve created the method tapOn wrote above too. But getDriver() and tapOn() is wrote in another class accessible for each test.

You want an exemple ?

---

<div class="post-metadata">

**Author:** ![ravikr42](https://discuss.appium.io/user_avatar/discuss.appium.io/ravikr42/32/1493_2.png) [@ravikr42](https://discuss.appium.io/u/ravikr42)\
**Post date:** [November 13, 2015, 2:48am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/20 "2015-11-13T02:48:20Z")

</div>

Hi @Julien_Blanc

That would be a great help, if you provide.

Appreciate your help.

---

<div class="post-metadata">

**Author:** ![Jaswitha](https://discuss.appium.io/letter_avatar_proxy/v4/letter/j/46a35a/32.png) [@Jaswitha](https://discuss.appium.io/u/Jaswitha)\
**Post date:** [February 23, 2016, 6:30am UTC](https://discuss.appium.io/t/difference-between-click-and-tap/295/21 "2016-02-23T06:30:18Z")

</div>

Hello,  
I have a query regarding tap function. I wanted to test a touch action on the object that we have created on the canvas . I tried using tap and click but it didn’t work me. And I am not able to see the object that I wanted to touch using ui automator. The object was a rectangle created by the 4 lines . Can someone suggest me how to perform touch on this object .

Thanks

[Next page](https://discuss.appium.io/t/difference-between-click-and-tap/295.md?page=2)
