Is there a way to continue to use tap keyword with appium 2.0?

I’m new on this forum and beginner on Robotframework. I’m running robot tests on iOS simulator iOS17 and I recently update appium to version v2. I noticed in the Appium library that Tap keyword is deprecated and i should use Tap With Positions.
But It is not really convenient to identify all the elements of my application by their coordinates.
So my question is: Is there a way to continue to use Tap keyword with appium 2.0?
I tried with Click Element but it seems to be less reliable than Tap for iOS simulators.

thank you for your answers

Hi Mia,

I’ll suggest you create a User keyword called something like Single Finger Tap that emulates the behaviour of what you used Tap for

Bearing in mind I don’t use appium myself, this is a guess based on the documentation so may require tuning, but this is what I would do in your situation:

*** Keywords ***
Single Finger Tap
    [Arguments]    ${locator}
    ${rect}=    Get Element Rect    ${locator}
    ${centre_x}=    Evaluate    ${rect}[x] + (${rect}[width] / 2)
    ${centre_y}=    Evaluate    ${rect}[y] + (${rect}[height] / 2)
    @{firstFinger}=    create list    ${centre_x}    ${centre_y}
    @{fingerPositions}=    create list    ${firstFinger}
    Tap with Positions    ${500}    @{fingerPositions} 	

Hope that helps,


1 Like

Mia, thanks for sharing this. And welcome to the Robot Framework Forum :robot:!! I am looking at the next generation AppiumLibrary and a big part of that is gestures. I like the idea of describing my automation step as “Tap this” or “Tap there” instead of saying coordinates. As a convenience keyword I do like Tap better than Tap with Positions. So one idea is to have the library automatically calculate the center position. Maybe one can enter a locator or a set of coordinates. I was also thinking that although I want my gestures and my tests to be consistent and deterministic I see the uses of mobile devices and human like gestures to be a bit random. So I am considering how one might choose to add this to gesture keywords. Noticing all the specific gesture there are within just the iOS docs I start to see an very large and ever expansive set of gesture keywords.

So as I think about the next generation of AppiumLibrary I think it would be good to talk about and describe all these gestures and see all the possibilities but then minimum or common set of keywords and arguments for gestures.



Thank you Dave for this idea.
I was not aware about Get Element Rect. I will try and i’ll let you know how it is going.

1 Like

There is also the option to use Click Element

1 Like

Hi Dave,
The keyword worked well with some changes for the duration. Thank you for the solution

1 Like