Skip to content
Closed
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
28 changes: 28 additions & 0 deletions src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,35 @@ public TouchAction tap(WebElement el, int x, int y) {
parameterBuilder.add(action);
return this;
}

/**
* 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;
}

/**
* A wait action, used as a NOP in multi-chaining.
*
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/io/appium/java_client/TouchShortcuts.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ public interface TouchShortcuts {
* @param el The element to pinch.
*/
void zoom(WebElement el);

/**
* Convenience method for double tapping element at a coordinate.
*
* @param element we want to double tap.
* @param x x coordinate.
* @param y y coordinate.
*/
void doubleTap(WebElement element, int x, int y);

/**
* Convenience method for double tapping center of an element.
*
* @param element we want to double tap.
*/
void doubleTap(WebElement element);

/**
* Convenience method for tapping a position on the screen.
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/io/appium/java_client/android/AndroidDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,18 @@ public void lockDevice() {
public void unlockDevice() {
CommandExecutionHelper.execute(this, unlockCommand());
}

/**
* @see TouchShortcuts#doubleTap(WebElement, int, int).
*/
@Override public void doubleTap(WebElement element, int x, int y) {
throw new UnsupportedOperationException("Support has not been added in the android driver.");
}

/**
* @see TouchShortcuts#doubleTap(WebElement).
*/
@Override public void doubleTap(WebElement element) {
throw new UnsupportedOperationException("Support has not been added in the android driver.");
}
}
17 changes: 17 additions & 0 deletions src/main/java/io/appium/java_client/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.FindsByIosUIAutomation;
import io.appium.java_client.MobileSelector;
import io.appium.java_client.TouchAction;
import io.appium.java_client.ios.internal.JsonToIOSElementConverter;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.service.local.AppiumDriverLocalService;
Expand Down Expand Up @@ -272,4 +273,20 @@ class IOSAlert implements Alert {
}

}

/**
* @see TouchShortcuts#doubleTap(WebElement, int, int).
*/
@Override public void doubleTap(WebElement element, int x, int y) {
TouchAction action = new TouchAction(this);
action.doubleTap(element, x, y).perform();
}

/**
* @see TouchShortcuts#doubleTap(WebElement).
*/
@Override public void doubleTap(WebElement element) {
TouchAction action = new TouchAction(this);
action.doubleTap(element).perform();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ public void swipe(int startx, int starty, int endx, int endy, int duration) {
.release();
swipeAction.perform();
}

/**
* @see TouchShortcuts#doubleTap(WebElement, int, int).
*/
@Override public void doubleTap(WebElement element, int x, int y) {
throw new UnsupportedOperationException("Support has not been added in the YouiEngineDriver.");
}

/**
* @see TouchShortcuts#doubleTap(WebElement).
*/
@Override public void doubleTap(WebElement element) {
throw new UnsupportedOperationException("Support has not been added in the YouiEngineDriver.");
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/openqa/selenium/WebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.openqa.selenium;

import org.openqa.selenium.logging.Logs;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.logging.Logs;

import java.net.URL;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AndroidGestureTest extends BaseAndroidTest {
assertEquals("ON" ,driver
.findElementById("io.appium.android.apis:id/button_toggle").getText());
}

@Test public void singleElementTapTest() throws Exception {
driver.startActivity("io.appium.android.apis", ".view.Buttons1");
driver.tap(1, driver.findElementById("io.appium.android.apis:id/button_toggle"), 1000);
Expand Down
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.SwipeElementDirection;
Expand All @@ -33,6 +34,14 @@ public class IOSGesturesTest extends BaseIOSTest {
driver.tap(2, e, 2000);
assertEquals(driver.findElementByXPath("//*[@name = \"Answer\"]").getText(), "6");
}

@Test public void doubleTapTest() {
IOSElement firstField = (IOSElement) driver.findElementById("IntegerA");
firstField.sendKeys("2");
driver.doubleTap(firstField);
IOSElement editingMenu = (IOSElement) driver.findElementByClassName("UIAEditingMenu");
assertNotNull(editingMenu);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was little to double tap on in ios TestApp. But found the editing menu shows up when you double tap on one of the fields.

}

@Test public void zoomTest() {
MobileElement e = driver.findElementById("IntegerA");
Expand Down