diff --git a/src/main/java/io/appium/java_client/TouchAction.java b/src/main/java/io/appium/java_client/TouchAction.java index 9666f9204..d3154287d 100644 --- a/src/main/java/io/appium/java_client/TouchAction.java +++ b/src/main/java/io/appium/java_client/TouchAction.java @@ -34,7 +34,7 @@ */ public class TouchAction { - private ImmutableList.Builder parameterBuilder; + protected ImmutableList.Builder parameterBuilder; private PerformsTouchActions performsTouchActions; public TouchAction(PerformsTouchActions performsTouchActions) { diff --git a/src/main/java/io/appium/java_client/ios/IOSTouchAction.java b/src/main/java/io/appium/java_client/ios/IOSTouchAction.java index e11292734..905eb1b94 100644 --- a/src/main/java/io/appium/java_client/ios/IOSTouchAction.java +++ b/src/main/java/io/appium/java_client/ios/IOSTouchAction.java @@ -4,6 +4,7 @@ import io.appium.java_client.PerformsTouchActions; import io.appium.java_client.TouchAction; import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.HasIdentity; public class IOSTouchAction extends TouchAction implements CreatesSwipeAction { @@ -28,4 +29,32 @@ public TouchAction swipe(int startX, int startY, WebElement element, int duratio public TouchAction swipe(WebElement element1, WebElement element2, int duration) { return press(element1).waitAction(duration).moveTo(element2).release(); } + + /** + * Double taps an element, offset from upper left corner. + * + * @param el element to tap. + * @param x x offset. + * @param y y offset. + * @return this TouchAction, for chaining. + */ + public TouchAction doubleTap(WebElement el, int x, int y) { + ActionParameter action = new ActionParameter("doubleTap", (HasIdentity) el); + action.addParameter("x", x); + action.addParameter("y", y); + parameterBuilder.add(action); + return this; + } + + /** + * Double taps an element, offset from upper left corner. + * + * @param el element to tap. + * @return this TouchAction, for chaining. + */ + public TouchAction doubleTap(WebElement el) { + ActionParameter action = new ActionParameter("doubleTap", (HasIdentity) el); + parameterBuilder.add(action); + return this; + } } diff --git a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java index 269fd3326..1cb7511b5 100644 --- a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java +++ b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java @@ -17,6 +17,7 @@ package io.appium.java_client.ios; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import io.appium.java_client.MobileElement; import io.appium.java_client.remote.AutomationName; @@ -100,6 +101,15 @@ public class XCUIAutomationTest { } catch (Exception e) { throw e; } + } + + @Test public void doubleTapTest() { + IOSElement firstField = (IOSElement) driver.findElementById("IntegerA"); + firstField.sendKeys("2"); + IOSTouchAction iosTouchAction = new IOSTouchAction(driver); + iosTouchAction.doubleTap(firstField); + IOSElement editingMenu = (IOSElement) driver.findElementByClassName("UIAEditingMenu"); + assertNotNull(editingMenu); } }