Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XCUIT Mode] DoubleTap Support #523

Merged
merged 1 commit into from
Nov 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class TouchAction {

private ImmutableList.Builder<ActionParameter> parameterBuilder;
protected ImmutableList.Builder<ActionParameter> parameterBuilder;
private PerformsTouchActions performsTouchActions;

public TouchAction(PerformsTouchActions performsTouchActions) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/appium/java_client/ios/IOSTouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
}
10 changes: 10 additions & 0 deletions src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}