Can't make a triple tap action work

Hello,

We have recently upgraded our tools. We upgraded our XCode from 5 to 6, and our Appium from 1.2 to 1.3. My environment currently looks like this:

Appium: 1.3.4
XCode: 6.1.1 w/ iOS 7 simluator added
OSX: 10.9.5
iOS SDK 8.0 with a 7.1 build target
Tests are written with the Java toolkit, but called from Spock/Groovy.

In the application, there is a full screen presentation which is dismissed with a triple tap action. Before the upgrade, this is how I did that:

driver.tap(1, element, 1)
driver.tap(1, element, 1)
driver.tap(1, element, 1)

That no longer works because, since the upgrades, the three statements are so slow that that the app sees this as three unrelated taps. My thinking is to unify the triple tap into one action. I have tried many variations, and none of them work. Here is my last failed attempt:

    def tripleTap = new TouchAction(driver).tap(100,100).tap(0,0).tap(0,0)
    tripleTap.perform()

I see in my log that this gets executed as this bit of javascript. I’m don’t know what to make of it, other than the fact that the app doesn’t act like it was triple tapped on:

target.touch([{"touch":[{"x":100,"y":100}],"time":0.2},{"touch":[{"x":100,"y":100}],"time":0.4},{"touch":[{"x":100,"y":100}],"time":0.6000000000000001}])

Can anyone help me find a triple tap method that works?

Thanks,
Gregor.

I noticed that while using the inspector there’s a “Precise Tap” option, that will let you pick the number of taps you’d like to perform, set the touch time, and then the “x,y” coordinates for your triple tap. Have you tried that?

I’ve not worked with the java bindings yet, but swapping the inspector to print Java code gave me something like this:

(JavascriptExecutor)wd.executeScript(“mobile: tap”, new HashMap<String, Double>() {{ put(“tapCount”, 3); put(“touchCount”, 1); put(“duration”, 0.5408399); put(“x”, 162); put(“y”, 229); }});

I’m currently using the following configuration and had similar issues:
Appium version 1.3.7
XCode version 6.2
OSX: 10.9.5
iOS SDK 8.1

I was able to find a workaround using JavascriptExecutor:

   >  //Triple tap on Element
    WebElement el = driver.findElementByXPath("//....your_element_path");
    double x = el.getLocation().x;
    double y = el.getLocation().y;
    JavascriptExecutor js = (JavascriptExecutor) driver;
    HashMap<String, Double> tapObject = new HashMap<String, Double>();
    tapObject.put("x", x);
    tapObject.put("y", y);
    tapObject.put("duration", 0.0);
    tapObject.put("touchCount", 1.0);
    tapObject.put("tapCount", 3.0);
    js.executeScript("mobile: tap", tapObject);

Make sure to specify 0.0 for the duration. For some reason not specifying this value doesn’t default properly. I tried different values for the duration and it wasn’t working for me but somehow 0.0 works great.

1 Like