From 2bb08635e58609832fdb1227f1e34c8feaceb163 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Sat, 3 Oct 2026 20:39:46 +0200 Subject: [PATCH] feat!: remove the deprecated touch actions API BREAKING CHANGE: TouchAction, MultiTouchAction, PerformsTouchActions, AndroidTouchAction, IOSTouchAction, the io.appium.java_client.touch and io.appium.java_client.ios.touch packages, and functions.ActionSupplier are removed. Drivers no longer implement PerformsTouchActions. Use W3C Actions or the driver's mobile: gesture extension methods instead. Co-Authored-By: Claude Sonnet 5.5 --- build.gradle | 1 - .../io/appium/java_client/MobileCommand.java | 8 - .../appium/java_client/MultiTouchAction.java | 103 -------- .../java_client/PerformsTouchActions.java | 76 ------ .../io/appium/java_client/TouchAction.java | 240 ------------------ .../java_client/android/AndroidDriver.java | 2 - .../android/AndroidTouchAction.java | 42 --- .../java_client/functions/ActionSupplier.java | 31 --- .../io/appium/java_client/ios/IOSDriver.java | 2 - .../java_client/ios/IOSTouchAction.java | 65 ----- .../ios/touch/IOSPressOptions.java | 59 ----- .../io/appium/java_client/mac/Mac2Driver.java | 2 - .../java_client/touch/ActionOptions.java | 41 --- .../java_client/touch/LongPressOptions.java | 63 ----- .../appium/java_client/touch/TapOptions.java | 58 ----- .../appium/java_client/touch/WaitOptions.java | 66 ----- .../AbstractOptionCombinedWithPosition.java | 51 ---- .../touch/offset/ElementOption.java | 112 -------- .../java_client/touch/offset/PointOption.java | 77 ------ .../java_client/windows/WindowsDriver.java | 2 - .../touch/offset/ElementOptionTest.java | 38 --- 21 files changed, 1139 deletions(-) delete mode 100644 src/main/java/io/appium/java_client/MultiTouchAction.java delete mode 100644 src/main/java/io/appium/java_client/PerformsTouchActions.java delete mode 100644 src/main/java/io/appium/java_client/TouchAction.java delete mode 100644 src/main/java/io/appium/java_client/android/AndroidTouchAction.java delete mode 100644 src/main/java/io/appium/java_client/functions/ActionSupplier.java delete mode 100644 src/main/java/io/appium/java_client/ios/IOSTouchAction.java delete mode 100644 src/main/java/io/appium/java_client/ios/touch/IOSPressOptions.java delete mode 100644 src/main/java/io/appium/java_client/touch/ActionOptions.java delete mode 100644 src/main/java/io/appium/java_client/touch/LongPressOptions.java delete mode 100644 src/main/java/io/appium/java_client/touch/TapOptions.java delete mode 100644 src/main/java/io/appium/java_client/touch/WaitOptions.java delete mode 100644 src/main/java/io/appium/java_client/touch/offset/AbstractOptionCombinedWithPosition.java delete mode 100644 src/main/java/io/appium/java_client/touch/offset/ElementOption.java delete mode 100644 src/main/java/io/appium/java_client/touch/offset/PointOption.java delete mode 100644 src/test/java/io/appium/java_client/touch/offset/ElementOptionTest.java diff --git a/build.gradle b/build.gradle index 83a54f4c2..a40538119 100644 --- a/build.gradle +++ b/build.gradle @@ -297,7 +297,6 @@ testing { exclude '**/AndroidElementTest.class' exclude '**/AndroidFunctionTest.class' exclude '**/AndroidSearchingTest.class' - exclude '**/AndroidTouchTest.class' exclude '**/AndroidViewMatcherTest.class' exclude '**/ExecuteCDPCommandTest.class' exclude '**/ExecuteDriverScriptTest.class' diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index b4df90047..f294aa4d6 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -56,10 +56,6 @@ public class MobileCommand { @Deprecated public static final String RUN_APP_IN_BACKGROUND; @Deprecated - protected static final String PERFORM_TOUCH_ACTION; - @Deprecated - protected static final String PERFORM_MULTI_TOUCH; - @Deprecated public static final String LAUNCH_APP; @Deprecated public static final String CLOSE_APP; @@ -200,8 +196,6 @@ public class MobileCommand { PULL_FILE = "pullFile"; PULL_FOLDER = "pullFolder"; RUN_APP_IN_BACKGROUND = "runAppInBackground"; - PERFORM_TOUCH_ACTION = "performTouchAction"; - PERFORM_MULTI_TOUCH = "performMultiTouch"; LAUNCH_APP = "launchApp"; CLOSE_APP = "closeApp"; GET_DEVICE_TIME = "getDeviceTime"; @@ -278,8 +272,6 @@ public class MobileCommand { commandRepository.put(PULL_FOLDER, postC("/session/:sessionId/appium/device/pull_folder")); commandRepository.put(HIDE_KEYBOARD, postC("/session/:sessionId/appium/device/hide_keyboard")); commandRepository.put(RUN_APP_IN_BACKGROUND, postC("/session/:sessionId/appium/app/background")); - commandRepository.put(PERFORM_TOUCH_ACTION, postC("/session/:sessionId/touch/perform")); - commandRepository.put(PERFORM_MULTI_TOUCH, postC("/session/:sessionId/touch/multi/perform")); commandRepository.put(LAUNCH_APP, postC("/session/:sessionId/appium/app/launch")); commandRepository.put(CLOSE_APP, postC("/session/:sessionId/appium/app/close")); commandRepository.put(LOCK, postC("/session/:sessionId/appium/device/lock")); diff --git a/src/main/java/io/appium/java_client/MultiTouchAction.java b/src/main/java/io/appium/java_client/MultiTouchAction.java deleted file mode 100644 index 5895588ba..000000000 --- a/src/main/java/io/appium/java_client/MultiTouchAction.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.stream.Collectors.toList; - -/** - * Used for Webdriver 3 multi-touch gestures - * See the Webriver 3 spec https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html - * The MultiTouchAction object is a collection of TouchAction objects - * (remember that TouchAction objects are in turn, a chain of individual actions) - * Add multiple TouchAction objects using the add() method. - * When perform() method is called, all actions are sent to the performsTouchActions. - * The performsTouchActions performs the first step of each TouchAction object simultaneously as a multi-touch - * "execution group". Conceptually, the number of TouchAction objects added to the MultiTouchAction - * is equal to the number of "fingers" or other appendages or tools touching the screen at the - * same time as part of this multi-gesture. Then the performsTouchActions performs the second step of each - * TouchAction object and another "execution group", and the third, and so on. - * Using a waitAction() action within a TouchAction takes up one of the slots in an - * "execution group", so these can be used to sync up complex actions. - * Calling perform() sends the action command to the Mobile Driver. Otherwise, more and - * more actions can be chained. - * - * @deprecated Touch actions are deprecated. - * Please use W3C Actions instead or the corresponding - * extension methods for the driver (if available). - * Check - * - https://www.youtube.com/watch?v=oAJ7jwMNFVU - * - https://www.headspin.io/blog/ios-specific-touch-action-methods - * - https://www.headspin.io/blog/automating-complex-gestures-with-the-w3c-actions-api - * for more details. - */ -@Deprecated -public class MultiTouchAction implements PerformsActions { - - private List actions; - private PerformsTouchActions performsTouchActions; - - public MultiTouchAction(PerformsTouchActions performsTouchActions) { - this.performsTouchActions = performsTouchActions; - actions = new ArrayList<>(); - } - - /** - * Add a TouchAction to this multi-touch gesture. - * - * @param action TouchAction to add to this gesture - * @return This MultiTouchAction, for chaining - */ - public MultiTouchAction add(TouchAction action) { - actions.add(action); - return this; - } - - /** - * Perform the multi-touch action on the mobile performsTouchActions. - */ - public MultiTouchAction perform() { - checkArgument(!actions.isEmpty(), - "MultiTouch action must have at least one TouchAction added before it can be performed"); - if (actions.size() > 1) { - performsTouchActions.performMultiTouchAction(this); - return this; - } //android doesn't like having multi-touch actions with only a single TouchAction... - performsTouchActions.performTouchAction(actions.get(0)); - return this; - } - - protected Map> getParameters() { - return Map.of("actions", - actions.stream().map(touchAction -> touchAction.getParameters().get("actions")).collect(toList()) - ); - } - - /** - * Clears all the existing touch actions and resets the instance to the initial state. - * - * @return this MultiTouchAction, for possible segmented-touches. - */ - protected MultiTouchAction clearActions() { - actions = new ArrayList<>(); - return this; - } -} diff --git a/src/main/java/io/appium/java_client/PerformsTouchActions.java b/src/main/java/io/appium/java_client/PerformsTouchActions.java deleted file mode 100644 index 46cfc0b50..000000000 --- a/src/main/java/io/appium/java_client/PerformsTouchActions.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client; - -import java.util.List; -import java.util.Map; - -import static io.appium.java_client.MobileCommand.PERFORM_MULTI_TOUCH; -import static io.appium.java_client.MobileCommand.PERFORM_TOUCH_ACTION; - -/** - * Touch actions are deprecated. - * Please use W3C Actions instead or the corresponding - * extension methods for the driver (if available). - * Check - * - https://www.youtube.com/watch?v=oAJ7jwMNFVU - * - https://www.headspin.io/blog/ios-specific-touch-action-methods - * - https://www.headspin.io/blog/automating-complex-gestures-with-the-w3c-actions-api - * for more details. - */ -@Deprecated -@SuppressWarnings({"unchecked", "rawtypes"}) -public interface PerformsTouchActions extends ExecutesMethod { - /** - * Performs a chain of touch actions, which together can be considered an - * entire gesture. See the Webriver 3 spec - * https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html - * It's more convenient to call the perform() method of the TouchAction - * object itself. - * All the existing touch action parameters will be wiped out after this method - * is called. - * - * @param touchAction A TouchAction object, which contains a list of individual - * touch actions to perform - * @return the same touch action object - */ - @Deprecated - default TouchAction performTouchAction(TouchAction touchAction) { - Map> parameters = touchAction.getParameters(); - execute(PERFORM_TOUCH_ACTION, parameters); - return touchAction.clearParameters(); - } - - /** - * Performs multiple TouchAction gestures at the same time, to simulate - * multiple fingers/touch inputs. See the Webriver 3 spec - * https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html - * It's more convenient to call the perform() method of the MultiTouchAction - * object. - * All the existing multi touch actions will be wiped out after this method - * is called. - * - * @param multiAction the MultiTouchAction object to perform. - * @return MultiTouchAction instance for chaining. - */ - @Deprecated - default MultiTouchAction performMultiTouchAction(MultiTouchAction multiAction) { - Map> parameters = multiAction.getParameters(); - execute(PERFORM_MULTI_TOUCH, parameters); - return multiAction.clearActions(); - } -} diff --git a/src/main/java/io/appium/java_client/TouchAction.java b/src/main/java/io/appium/java_client/TouchAction.java deleted file mode 100644 index 21062ef95..000000000 --- a/src/main/java/io/appium/java_client/TouchAction.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client; - -import io.appium.java_client.touch.ActionOptions; -import io.appium.java_client.touch.LongPressOptions; -import io.appium.java_client.touch.TapOptions; -import io.appium.java_client.touch.WaitOptions; -import io.appium.java_client.touch.offset.ElementOption; -import io.appium.java_client.touch.offset.PointOption; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static java.util.Objects.requireNonNull; -import static java.util.stream.Collectors.toList; - -/** - * Used for Webdriver 3 touch actions - * See the Webriver 3 spec - * https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html - * The flow is to chain individual touch actions into an entire gesture. e.g. - * TouchAction action = new TouchAction(performsTouchActions); - * action.press(element).waitAction(300).moveTo(element1).release().perform(); - * Calling perform() sends the action command to the Mobile Driver. Otherwise, - * more and more actions can be chained. - * - * @deprecated Touch actions are deprecated. - * Please use W3C Actions instead or the corresponding - * extension methods for the driver (if available). - * Check - * - https://www.youtube.com/watch?v=oAJ7jwMNFVU - * - https://www.headspin.io/blog/ios-specific-touch-action-methods - * - https://www.headspin.io/blog/automating-complex-gestures-with-the-w3c-actions-api - * for more details. - */ -@Deprecated -public class TouchAction> implements PerformsActions { - - protected List parameters; - private PerformsTouchActions performsTouchActions; - - public TouchAction(PerformsTouchActions performsTouchActions) { - this.performsTouchActions = requireNonNull(performsTouchActions); - parameters = new ArrayList<>(); - } - - /** - * Press action on the screen. - * - * @param pressOptions see {@link PointOption} and {@link ElementOption}. - * @return this TouchAction, for chaining. - */ - public T press(PointOption pressOptions) { - parameters.add(new ActionParameter("press", pressOptions)); - //noinspection unchecked - return (T) this; - } - - /** - * Remove the current touching implement from the screen (withdraw your touch). - * - * @return this TouchAction, for chaining. - */ - public T release() { - parameters.add(new ActionParameter("release")); - //noinspection unchecked - return (T) this; - } - - /** - * Moves current touch to a new position. - * - * @param moveToOptions see {@link PointOption} and {@link ElementOption} - * Important: some older Appium drivers releases have a bug when moveTo - * coordinates are calculated as relative to the recent pointer position - * in the chain instead of being absolute. - * @see Appium Issue #7486 - * for more details. - * @return this TouchAction, for chaining. - */ - public T moveTo(PointOption moveToOptions) { - parameters.add(new ActionParameter("moveTo", moveToOptions)); - return (T) this; - } - - /** - * Tap on an element. - * - * @param tapOptions see {@link TapOptions}. - * @return this TouchAction, for chaining. - */ - public T tap(TapOptions tapOptions) { - parameters.add(new ActionParameter("tap", tapOptions)); - return (T) this; - } - - /** - * Tap on a position. - * - * @param tapOptions see {@link PointOption} and {@link ElementOption} - * @return this TouchAction, for chaining. - */ - public T tap(PointOption tapOptions) { - parameters.add(new ActionParameter("tap", tapOptions)); - return (T) this; - } - - /** - * A wait action, used as a NOP in multi-chaining. - * - * @return this TouchAction, for chaining. - */ - public T waitAction() { - parameters.add(new ActionParameter("wait")); - //noinspection unchecked - return (T) this; - } - - /** - * Waits for specified amount of time to pass before continue to next touch action. - * - * @param waitOptions see {@link WaitOptions}. - * @return this TouchAction, for chaining. - */ - public T waitAction(WaitOptions waitOptions) { - parameters.add(new ActionParameter("wait", waitOptions)); - //noinspection unchecked - return (T) this; - } - - /** - * Press and hold the at the center of an element until the context menu event has fired. - * - * @param longPressOptions see {@link LongPressOptions}. - * @return this TouchAction, for chaining. - */ - public T longPress(LongPressOptions longPressOptions) { - parameters.add(new ActionParameter("longPress", longPressOptions)); - //noinspection unchecked - return (T) this; - } - - /** - * Press and hold the at the center of an element until the context menu event has fired. - * - * @param longPressOptions see {@link PointOption} and {@link ElementOption}. - * @return this TouchAction, for chaining. - */ - public T longPress(PointOption longPressOptions) { - parameters.add(new ActionParameter("longPress", longPressOptions)); - //noinspection unchecked - return (T) this; - } - - /** - * Cancel this action, if it was partially completed by the performsTouchActions. - */ - public void cancel() { - parameters.add(new ActionParameter("cancel")); - this.perform(); - } - - /** - * Perform this chain of actions on the performsTouchActions. - * - * @return this TouchAction, for possible segmented-touches. - */ - public T perform() { - performsTouchActions.performTouchAction(this); - //noinspection unchecked - return (T) this; - } - - /** - * Get the mjsonwp parameters for this Action. - * - * @return A map of parameters for this touch action to pass as part of mjsonwp. - */ - protected Map> getParameters() { - return Map.of("actions", - parameters.stream().map(ActionParameter::getParameterMap).collect(toList()) - ); - } - - /** - * Clears all the existing action parameters and resets the instance to the initial state. - * - * @return this TouchAction, for possible segmented-touches. - */ - protected T clearParameters() { - parameters = new ArrayList<>(); - //noinspection unchecked - return (T) this; - } - - /** - * Just holds values to eventually return the parameters required for the mjsonwp. - */ - protected class ActionParameter { - private final String actionName; - private final Map options; - - public ActionParameter(String actionName) { - this.actionName = actionName; - options = new HashMap<>(); - } - - public ActionParameter(String actionName, ActionOptions opts) { - this(actionName); - requireNonNull(opts); - //noinspection unchecked - options.putAll(opts.build()); - } - - public Map getParameterMap() { - return Map.of( - "action", actionName, - "options", Collections.unmodifiableMap(options) - ); - } - } -} diff --git a/src/main/java/io/appium/java_client/android/AndroidDriver.java b/src/main/java/io/appium/java_client/android/AndroidDriver.java index aa1d30159..f850a4204 100644 --- a/src/main/java/io/appium/java_client/android/AndroidDriver.java +++ b/src/main/java/io/appium/java_client/android/AndroidDriver.java @@ -26,7 +26,6 @@ import io.appium.java_client.HidesKeyboard; import io.appium.java_client.InteractsWithApps; import io.appium.java_client.LocksDevice; -import io.appium.java_client.PerformsTouchActions; import io.appium.java_client.PullsFiles; import io.appium.java_client.PushesFiles; import io.appium.java_client.android.connection.HasNetworkConnection; @@ -56,7 +55,6 @@ public class AndroidDriver extends AppiumDriver implements SupportsRotation, SupportsContextSwitching, SupportsLocation, - PerformsTouchActions, HidesKeyboard, HasDeviceTime, PullsFiles, diff --git a/src/main/java/io/appium/java_client/android/AndroidTouchAction.java b/src/main/java/io/appium/java_client/android/AndroidTouchAction.java deleted file mode 100644 index 55f167604..000000000 --- a/src/main/java/io/appium/java_client/android/AndroidTouchAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.android; - -import io.appium.java_client.PerformsTouchActions; -import io.appium.java_client.TouchAction; - - -/** - * Android-specific touch action. - * - * @deprecated Touch actions are deprecated. - * Please use W3C Actions instead or the corresponding - * extension methods for the driver (if available). - * Check - * - https://www.youtube.com/watch?v=oAJ7jwMNFVU - * - https://www.headspin.io/blog/ios-specific-touch-action-methods - * - https://www.headspin.io/blog/automating-complex-gestures-with-the-w3c-actions-api - * for more details. - */ -@Deprecated -public class AndroidTouchAction extends TouchAction { - - public AndroidTouchAction(PerformsTouchActions performsTouchActions) { - super(performsTouchActions); - } - -} diff --git a/src/main/java/io/appium/java_client/functions/ActionSupplier.java b/src/main/java/io/appium/java_client/functions/ActionSupplier.java deleted file mode 100644 index 67ea8b888..000000000 --- a/src/main/java/io/appium/java_client/functions/ActionSupplier.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.functions; - -import io.appium.java_client.PerformsActions; - -import java.util.function.Supplier; - -/** - * Represents a supplier of actions. - * - * @deprecated Use {@link Supplier} instead - */ -@Deprecated -@FunctionalInterface -public interface ActionSupplier> extends Supplier { -} diff --git a/src/main/java/io/appium/java_client/ios/IOSDriver.java b/src/main/java/io/appium/java_client/ios/IOSDriver.java index 0fd5cbf20..6d42d0628 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -26,7 +26,6 @@ import io.appium.java_client.HidesKeyboardWithKeyName; import io.appium.java_client.InteractsWithApps; import io.appium.java_client.LocksDevice; -import io.appium.java_client.PerformsTouchActions; import io.appium.java_client.PullsFiles; import io.appium.java_client.PushesFiles; import io.appium.java_client.battery.HasBattery; @@ -62,7 +61,6 @@ public class IOSDriver extends AppiumDriver implements PullsFiles, InteractsWithApps, HasAppStrings, - PerformsTouchActions, HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings, diff --git a/src/main/java/io/appium/java_client/ios/IOSTouchAction.java b/src/main/java/io/appium/java_client/ios/IOSTouchAction.java deleted file mode 100644 index 0414726d0..000000000 --- a/src/main/java/io/appium/java_client/ios/IOSTouchAction.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.ios; - -import io.appium.java_client.PerformsTouchActions; -import io.appium.java_client.TouchAction; -import io.appium.java_client.ios.touch.IOSPressOptions; -import io.appium.java_client.touch.offset.ElementOption; -import io.appium.java_client.touch.offset.PointOption; - -/** - * iOS-specific touch action. - * - * @deprecated Touch actions are deprecated. - * Please use W3C Actions instead or the corresponding - * extension methods for the driver (if available). - * Check - * - https://www.youtube.com/watch?v=oAJ7jwMNFVU - * - https://www.headspin.io/blog/ios-specific-touch-action-methods - * - https://www.headspin.io/blog/automating-complex-gestures-with-the-w3c-actions-api - * for more details. - */ -@Deprecated -public class IOSTouchAction extends TouchAction { - - public IOSTouchAction(PerformsTouchActions performsTouchActions) { - super(performsTouchActions); - } - - /** - * Double taps using coordinates. - * - * @param doubleTapOption see {@link PointOption} and {@link ElementOption}.. - * @return self-reference - */ - public IOSTouchAction doubleTap(PointOption doubleTapOption) { - parameters.add(new ActionParameter("doubleTap", doubleTapOption)); - return this; - } - - /** - * Press action on the screen. - * - * @param pressOptions see {@link IOSPressOptions} - * @return this TouchAction, for chaining. - */ - public IOSTouchAction press(IOSPressOptions pressOptions) { - parameters.add(new ActionParameter("press", pressOptions)); - return this; - } -} diff --git a/src/main/java/io/appium/java_client/ios/touch/IOSPressOptions.java b/src/main/java/io/appium/java_client/ios/touch/IOSPressOptions.java deleted file mode 100644 index a6b8cdf7f..000000000 --- a/src/main/java/io/appium/java_client/ios/touch/IOSPressOptions.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.ios.touch; - -import io.appium.java_client.touch.offset.AbstractOptionCombinedWithPosition; - -import java.util.Map; - -import static java.util.Optional.ofNullable; - -public class IOSPressOptions extends AbstractOptionCombinedWithPosition { - private Double pressure = null; - - /** - * It creates an empty instance of {@link IOSPressOptions}. - * - * @return an empty instance of {@link IOSPressOptions} - */ - public static IOSPressOptions iosPressOptions() { - return new IOSPressOptions(); - } - - /** - * Set the pressure value. This allows to simulate force/3D touch on - * devices, that support it. - * - * @param pressure the value to set. - * See the description of `force` property on Apple's UITouch class - * (https://developer.apple.com/documentation/uikit/uitouch?language=objc) - * for more details on possible value ranges. - * - * @return this instance for chaining. - */ - public IOSPressOptions withPressure(double pressure) { - this.pressure = pressure; - return this; - } - - @Override - public Map build() { - final Map result = super.build(); - ofNullable(pressure).ifPresent(x -> result.put("pressure", x)); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/mac/Mac2Driver.java b/src/main/java/io/appium/java_client/mac/Mac2Driver.java index 46911c314..087beffdc 100644 --- a/src/main/java/io/appium/java_client/mac/Mac2Driver.java +++ b/src/main/java/io/appium/java_client/mac/Mac2Driver.java @@ -18,7 +18,6 @@ import io.appium.java_client.AppiumClientConfig; import io.appium.java_client.AppiumDriver; -import io.appium.java_client.PerformsTouchActions; import io.appium.java_client.remote.AutomationName; import io.appium.java_client.screenrecording.CanRecordScreen; import io.appium.java_client.service.local.AppiumDriverLocalService; @@ -41,7 +40,6 @@ * @since Appium 1.20.0 */ public class Mac2Driver extends AppiumDriver implements - PerformsTouchActions, CanRecordScreen { private static final String PLATFORM_NAME = Platform.MAC.name(); private static final String AUTOMATION_NAME = AutomationName.MAC2; diff --git a/src/main/java/io/appium/java_client/touch/ActionOptions.java b/src/main/java/io/appium/java_client/touch/ActionOptions.java deleted file mode 100644 index 2514a92a5..000000000 --- a/src/main/java/io/appium/java_client/touch/ActionOptions.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.touch; - -import java.util.HashMap; -import java.util.Map; - -@Deprecated -public abstract class ActionOptions> { - /** - * This method is automatically called before building - * options map to verify the consistency of the instance. - * - * @throws IllegalArgumentException if there are problems with this options map. - */ - protected abstract void verify(); - - /** - * Creates a map based on the provided options. - * - * @return options mapping. - */ - public Map build() { - verify(); - return new HashMap<>(); - } -} diff --git a/src/main/java/io/appium/java_client/touch/LongPressOptions.java b/src/main/java/io/appium/java_client/touch/LongPressOptions.java deleted file mode 100644 index 56d2334fb..000000000 --- a/src/main/java/io/appium/java_client/touch/LongPressOptions.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.touch; - -import io.appium.java_client.touch.offset.AbstractOptionCombinedWithPosition; - -import java.time.Duration; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; -import static java.util.Optional.ofNullable; - -@Deprecated -public class LongPressOptions extends AbstractOptionCombinedWithPosition { - protected Duration duration = null; - - /** - * It creates an empty instance of {@link LongPressOptions}. - * - * @return an empty instance of {@link LongPressOptions} - */ - public static LongPressOptions longPressOptions() { - return new LongPressOptions(); - } - - /** - * Set the long press duration. - * - * @param duration the value to set. - * Time resolution unit is 1 ms. - * @return this instance for chaining. - */ - public LongPressOptions withDuration(Duration duration) { - requireNonNull(duration); - checkArgument(duration.toMillis() >= 0, - "Duration value should be greater or equal to zero"); - this.duration = duration; - return this; - } - - @Override - public Map build() { - final Map result = super.build(); - ofNullable(duration).ifPresent(durationParam -> - result.put("duration", durationParam.toMillis())); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/touch/TapOptions.java b/src/main/java/io/appium/java_client/touch/TapOptions.java deleted file mode 100644 index 7dee99fae..000000000 --- a/src/main/java/io/appium/java_client/touch/TapOptions.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.touch; - -import io.appium.java_client.touch.offset.AbstractOptionCombinedWithPosition; - -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Optional.ofNullable; - -@Deprecated -public class TapOptions extends AbstractOptionCombinedWithPosition { - private Integer tapsCount = null; - - /** - * It creates an empty instance of {@link TapOptions}. - * - * @return the empty instance of {@link TapOptions} - */ - public static TapOptions tapOptions() { - return new TapOptions(); - } - - /** - * Set the count of taps to perform. - * - * @param tapsCount the taps count to perform. - * The value should be greater than zero. - * @return this instance for chaining. - */ - public TapOptions withTapsCount(int tapsCount) { - checkArgument(tapsCount > 0, "Taps count should be greater than zero"); - this.tapsCount = tapsCount; - return this; - } - - @Override - public Map build() { - final Map result = super.build(); - ofNullable(tapsCount).ifPresent(integer -> result.put("count", integer)); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/touch/WaitOptions.java b/src/main/java/io/appium/java_client/touch/WaitOptions.java deleted file mode 100644 index 11eb0ccdc..000000000 --- a/src/main/java/io/appium/java_client/touch/WaitOptions.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.appium.java_client.touch; - -import java.time.Duration; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.time.Duration.ofMillis; -import static java.util.Objects.requireNonNull; - -@Deprecated -public class WaitOptions extends ActionOptions { - protected Duration duration = ofMillis(0); - - /** - * Creates and instance of {@link WaitOptions}. - * - * @param duration is the duration of the waiting. - * @return a built option. - */ - public static WaitOptions waitOptions(Duration duration) { - return new WaitOptions().withDuration(duration); - } - - /** - * Set the wait duration. - * - * @param duration the value to set. - * Time resolution unit is 1 ms. - * @return this instance for chaining. - */ - public WaitOptions withDuration(Duration duration) { - requireNonNull(duration); - checkArgument(duration.toMillis() >= 0, - "Duration value should be greater or equal to zero"); - this.duration = duration; - return this; - } - - @Override - protected void verify() { - //there is nothing to check - } - - @Override - public Map build() { - final Map result = super.build(); - result.put("ms", duration.toMillis()); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/touch/offset/AbstractOptionCombinedWithPosition.java b/src/main/java/io/appium/java_client/touch/offset/AbstractOptionCombinedWithPosition.java deleted file mode 100644 index 194228eea..000000000 --- a/src/main/java/io/appium/java_client/touch/offset/AbstractOptionCombinedWithPosition.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.appium.java_client.touch.offset; - -import io.appium.java_client.touch.ActionOptions; - -import java.util.Map; - -import static java.util.Optional.ofNullable; - -@Deprecated -public abstract class AbstractOptionCombinedWithPosition> - extends ActionOptions> { - private ActionOptions positionOption; - - /** - * Some actions may require coordinates. Invocation of this method - * replaces the result of previous {@link #withElement(ElementOption)} invocation. - * - * @param positionOption required coordinates. * - * @return self-reference - */ - public T withPosition(PointOption positionOption) { - this.positionOption = positionOption; - return (T) this; - } - - /** - * Most of touch action may use position which is relative to some element. In order to unify - * this behaviour this method was added. Invocation of this method - * replaces the result of previous {@link #withPosition(PointOption)} invocation. - * - * @param element required position which is relative to some element - * @return self-reference - */ - public T withElement(ElementOption element) { - positionOption = element; - return (T) this; - } - - protected void verify() { - ofNullable(positionOption).orElseThrow(() -> - new IllegalArgumentException("Some coordinates or an offset from an element should " - + "be defined. Use withPosition or withElement methods")); - } - - @Override - public Map build() { - final Map result = super.build(); - result.putAll(positionOption.build()); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/touch/offset/ElementOption.java b/src/main/java/io/appium/java_client/touch/offset/ElementOption.java deleted file mode 100644 index 3adae2d86..000000000 --- a/src/main/java/io/appium/java_client/touch/offset/ElementOption.java +++ /dev/null @@ -1,112 +0,0 @@ -package io.appium.java_client.touch.offset; - -import org.openqa.selenium.Point; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.RemoteWebElement; - -import java.util.HashMap; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; -import static java.util.Optional.ofNullable; - -@Deprecated -public class ElementOption extends PointOption { - - private String elementId; - - /** - * This method creates a build instance of the {@link ElementOption}. - * - * @param element is the element to calculate offset from. - * @param offset is the offset from the upper left corner of the given element. - * @return the built option - */ - public static ElementOption element(WebElement element, Point offset) { - return new ElementOption().withElement(element).withCoordinates(offset); - } - - - /** - * This method creates a build instance of the {@link ElementOption}. - * - * @param element is the element to calculate offset from. - * @param x is the x-offset from the upper left corner of the given element. - * @param y is the y-offset from the upper left corner of the given element. - * @return the built option - */ - public static ElementOption element(WebElement element, int x, int y) { - return new ElementOption().withElement(element).withCoordinates(x, y); - } - - /** - * This method creates a build instance of the {@link ElementOption}. - * - * @param element is the element to calculate offset from. - * @return the built option - */ - public static ElementOption element(WebElement element) { - return new ElementOption().withElement(element); - } - - /** - * It defines x and y offset from the upper left corner of an element. - * - * @param offset is the offset from the upper left corner of the given element. - * @return self-reference - */ - @Override - public ElementOption withCoordinates(Point offset) { - super.withCoordinates(offset); - return this; - } - - /** - * It defines x and y offset from the upper left corner of an element. - * - * @param xOffset is the x-offset from the upper left corner of the given element. - * @param yOffset is the y-offset from the upper left corner of the given element. - * @return self-reference - */ - @Override - public ElementOption withCoordinates(int xOffset, int yOffset) { - super.withCoordinates(xOffset, yOffset); - return this; - } - - /** - * This method sets the element as an option. It means that x/y offset is the offset - * from the upper left corner of the given element. - * - * @param element is the element to calculate offset from. - * @return self-reference - */ - public ElementOption withElement(WebElement element) { - requireNonNull(element); - checkArgument(element instanceof RemoteWebElement, - "Element should be an instance of the class which " - + "extends org.openqa.selenium.remote.RemoteWebElement"); - elementId = ((RemoteWebElement) element).getId(); - return this; - } - - @Override - protected void verify() { - ofNullable(elementId).orElseThrow(() -> - new IllegalArgumentException("Element should be defined")); - } - - @Override - public Map build() { - verify(); - final Map result = new HashMap<>(); - result.put("element", elementId); - - ofNullable(coordinates).ifPresent(point -> { - result.put("x", point.x); - result.put("y", point.y); - }); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/touch/offset/PointOption.java b/src/main/java/io/appium/java_client/touch/offset/PointOption.java deleted file mode 100644 index a45d59f9c..000000000 --- a/src/main/java/io/appium/java_client/touch/offset/PointOption.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.appium.java_client.touch.offset; - -import io.appium.java_client.touch.ActionOptions; -import org.openqa.selenium.Point; - -import java.util.Map; - -import static java.util.Optional.ofNullable; - -@Deprecated -public class PointOption> extends ActionOptions { - - protected Point coordinates; - - /** - * It creates a built instance of {@link PointOption} which takes x and y coordinates. - * This is offset from the upper left corner of the screen. - * - * @param offset is an offset value. - * @return a built option - */ - public static PointOption point(Point offset) { - return new PointOption().withCoordinates(offset); - } - - /** - * It creates a built instance of {@link PointOption} which takes x and y coordinates. - * This is offset from the upper left corner of the screen. - * - * @param xOffset is x value. - * @param yOffset is y value. - * @return a built option - */ - public static PointOption point(int xOffset, int yOffset) { - return new PointOption().withCoordinates(xOffset, yOffset); - } - - /** - * It defines x and y coordinates. - * This is offset from the upper left corner of the screen. - * - * @param offset is an offset value. - * @return self-reference - */ - public T withCoordinates(Point offset) { - return withCoordinates(offset.x, offset.y); - } - - /** - * It defines x and y coordinates. - * This is offset from the upper left corner of the screen. - * - * @param xOffset is x value. - * @param yOffset is y value. - * @return self-reference - */ - public T withCoordinates(int xOffset, int yOffset) { - coordinates = new Point(xOffset, yOffset); - //noinspection unchecked - return (T) this; - } - - @Override - protected void verify() { - //noinspection ResultOfMethodCallIgnored - ofNullable(coordinates).orElseThrow(() -> new IllegalArgumentException( - "Coordinate values must be defined")); - } - - @Override - public Map build() { - final Map result = super.build(); - result.put("x", coordinates.x); - result.put("y", coordinates.y); - return result; - } -} diff --git a/src/main/java/io/appium/java_client/windows/WindowsDriver.java b/src/main/java/io/appium/java_client/windows/WindowsDriver.java index 7c6e68a7a..62c5b32eb 100644 --- a/src/main/java/io/appium/java_client/windows/WindowsDriver.java +++ b/src/main/java/io/appium/java_client/windows/WindowsDriver.java @@ -19,7 +19,6 @@ import io.appium.java_client.AppiumClientConfig; import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileCommand; -import io.appium.java_client.PerformsTouchActions; import io.appium.java_client.PullsFiles; import io.appium.java_client.PushesFiles; import io.appium.java_client.remote.AutomationName; @@ -35,7 +34,6 @@ import java.net.URL; public class WindowsDriver extends AppiumDriver implements - PerformsTouchActions, PullsFiles, PushesFiles, CanRecordScreen { diff --git a/src/test/java/io/appium/java_client/touch/offset/ElementOptionTest.java b/src/test/java/io/appium/java_client/touch/offset/ElementOptionTest.java deleted file mode 100644 index 50da066c6..000000000 --- a/src/test/java/io/appium/java_client/touch/offset/ElementOptionTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.appium.java_client.touch.offset; - -import org.junit.jupiter.api.Test; -import org.openqa.selenium.WebElement; - -import java.lang.reflect.Proxy; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class ElementOptionTest { - - @Test - void withElementRejectsNonRemoteWebElement() { - WebElement stub = (WebElement) Proxy.newProxyInstance( - WebElement.class.getClassLoader(), - new Class[]{WebElement.class}, - (proxy, method, args) -> { - if ("toString".equals(method.getName())) { - return "stub-web-element"; - } - if (method.getReturnType().equals(boolean.class)) { - return false; - } - if (method.getReturnType().equals(int.class)) { - return 0; - } - return null; - }); - - IllegalArgumentException thrown = assertThrows( - IllegalArgumentException.class, - () -> ElementOption.element(stub)); - - assertThat(thrown.getMessage(), containsString("RemoteWebElement")); - } -}