Skip to content

Commit 6eea65f

Browse files
Merge pull request #523 from SrinivasanTarget/master
[XCUIT Mode] DoubleTap Support
2 parents da32b8e + 739638a commit 6eea65f

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/main/java/io/appium/java_client/TouchAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
public class TouchAction {
3636

37-
private ImmutableList.Builder<ActionParameter> parameterBuilder;
37+
protected ImmutableList.Builder<ActionParameter> parameterBuilder;
3838
private PerformsTouchActions performsTouchActions;
3939

4040
public TouchAction(PerformsTouchActions performsTouchActions) {

src/main/java/io/appium/java_client/ios/IOSTouchAction.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.appium.java_client.PerformsTouchActions;
55
import io.appium.java_client.TouchAction;
66
import org.openqa.selenium.WebElement;
7+
import org.openqa.selenium.internal.HasIdentity;
78

89

910
public class IOSTouchAction extends TouchAction implements CreatesSwipeAction {
@@ -28,4 +29,32 @@ public TouchAction swipe(int startX, int startY, WebElement element, int duratio
2829
public TouchAction swipe(WebElement element1, WebElement element2, int duration) {
2930
return press(element1).waitAction(duration).moveTo(element2).release();
3031
}
32+
33+
/**
34+
* Double taps an element, offset from upper left corner.
35+
*
36+
* @param el element to tap.
37+
* @param x x offset.
38+
* @param y y offset.
39+
* @return this TouchAction, for chaining.
40+
*/
41+
public TouchAction doubleTap(WebElement el, int x, int y) {
42+
ActionParameter action = new ActionParameter("doubleTap", (HasIdentity) el);
43+
action.addParameter("x", x);
44+
action.addParameter("y", y);
45+
parameterBuilder.add(action);
46+
return this;
47+
}
48+
49+
/**
50+
* Double taps an element, offset from upper left corner.
51+
*
52+
* @param el element to tap.
53+
* @return this TouchAction, for chaining.
54+
*/
55+
public TouchAction doubleTap(WebElement el) {
56+
ActionParameter action = new ActionParameter("doubleTap", (HasIdentity) el);
57+
parameterBuilder.add(action);
58+
return this;
59+
}
3160
}

src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.appium.java_client.ios;
1818

1919
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertNotNull;
2021

2122
import io.appium.java_client.MobileElement;
2223
import io.appium.java_client.remote.AutomationName;
@@ -100,6 +101,15 @@ public class XCUIAutomationTest {
100101
} catch (Exception e) {
101102
throw e;
102103
}
104+
}
105+
106+
@Test public void doubleTapTest() {
107+
IOSElement firstField = (IOSElement) driver.findElementById("IntegerA");
108+
firstField.sendKeys("2");
103109

110+
IOSTouchAction iosTouchAction = new IOSTouchAction(driver);
111+
iosTouchAction.doubleTap(firstField);
112+
IOSElement editingMenu = (IOSElement) driver.findElementByClassName("UIAEditingMenu");
113+
assertNotNull(editingMenu);
104114
}
105115
}

0 commit comments

Comments
 (0)