From d28f27e92a88631a14344e386281abdbcbf589f3 Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Sun, 18 Jun 2017 00:57:00 +0300 Subject: [PATCH] 5.0.0 finalization. Removal of obsolete code. --- .../io/appium/java_client/AppiumDriver.java | 127 ---------- .../io/appium/java_client/AppiumSetting.java | 38 --- .../DefaultGenericMobileElement.java | 2 +- .../java_client/DeviceActionShortcuts.java | 49 ---- .../appium/java_client/InteractsWithApps.java | 13 -- .../io/appium/java_client/MobileCommand.java | 14 -- .../io/appium/java_client/MobileElement.java | 41 ---- .../java_client/SwipeElementDirection.java | 217 ------------------ .../io/appium/java_client/TouchAction.java | 56 ----- .../appium/java_client/TouchableElement.java | 123 ---------- .../android/AndroidDeviceActionShortcuts.java | 75 ------ .../java_client/android/AndroidDriver.java | 8 - .../android/AndroidMobileCommandHelper.java | 50 ---- .../android/HasAndroidSettings.java | 55 ----- .../android/LocksAndroidDevice.java | 5 +- .../java_client/android/StartsActivity.java | 102 -------- .../JsonToAndroidElementConverter.java | 41 ---- .../java_client/internal/ElementMap.java | 2 - .../ios/IOSDeviceActionShortcuts.java | 65 ------ .../io/appium/java_client/ios/IOSDriver.java | 22 +- .../ios/IOSMobileCommandHelper.java | 30 --- .../java_client/ios/LocksIOSDevice.java | 11 - .../internal/JsonToIOSElementConverter.java | 41 ---- .../pagefactory/AppiumFieldDecorator.java | 4 +- .../youiengine/YouiEngineDriver.java | 46 ---- .../youiengine/YouiEngineElement.java | 29 --- .../JsonToYouiEngineElementConverter.java | 42 ---- .../android/AndroidDriverTest.java | 10 +- .../java_client/ios/XCUIAutomationTest.java | 6 +- 29 files changed, 18 insertions(+), 1306 deletions(-) delete mode 100644 src/main/java/io/appium/java_client/AppiumSetting.java delete mode 100644 src/main/java/io/appium/java_client/DeviceActionShortcuts.java delete mode 100644 src/main/java/io/appium/java_client/SwipeElementDirection.java delete mode 100644 src/main/java/io/appium/java_client/TouchableElement.java delete mode 100644 src/main/java/io/appium/java_client/android/AndroidDeviceActionShortcuts.java delete mode 100644 src/main/java/io/appium/java_client/android/internal/JsonToAndroidElementConverter.java delete mode 100644 src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java delete mode 100644 src/main/java/io/appium/java_client/ios/internal/JsonToIOSElementConverter.java delete mode 100644 src/main/java/io/appium/java_client/youiengine/YouiEngineDriver.java delete mode 100644 src/main/java/io/appium/java_client/youiengine/YouiEngineElement.java delete mode 100644 src/main/java/io/appium/java_client/youiengine/internal/JsonToYouiEngineElementConverter.java diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index 1cd9219af..54bf7708e 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -32,8 +32,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.DeviceRotation; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.Point; import org.openqa.selenium.ScreenOrientation; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; @@ -208,131 +206,6 @@ public List findElementsByXPath(String using) { return executeMethod; } - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void tap(int fingers, WebElement element, int duration) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - for (int i = 0; i < fingers; i++) { - TouchAction tap = new TouchAction(this); - multiTouch.add(tap.press(element).waitAction(duration).release()); - } - - multiTouch.perform(); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void tap(int fingers, int x, int y, int duration) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - for (int i = 0; i < fingers; i++) { - TouchAction tap = new TouchAction(this); - multiTouch.add(tap.press(x,y).waitAction(duration).release()); - } - multiTouch.perform(); - } - - /** - * This method is deprecated. It is going to be removed - */ - @Deprecated - public void swipe(int startx, int starty, int endx, int endy, int duration) { - //does nothing - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void pinch(WebElement el) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - Dimension dimensions = el.getSize(); - Point upperLeft = el.getLocation(); - Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, - upperLeft.getY() + dimensions.getHeight() / 2); - int yOffset = center.getY() - upperLeft.getY(); - - TouchAction action0 = - new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el) - .release(); - TouchAction action1 = - new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el) - .release(); - - multiTouch.add(action0).add(action1).perform(); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void pinch(int x, int y) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - int scrHeight = this.manage().window().getSize().getHeight(); - int yOffset = 100; - - if (y - 100 < 0) { - yOffset = y; - } else if (y + 100 > scrHeight) { - yOffset = scrHeight - y; - } - - TouchAction action0 = new TouchAction(this).press(x, y - yOffset).moveTo(x, y).release(); - TouchAction action1 = new TouchAction(this).press(x, y + yOffset).moveTo(x, y).release(); - - multiTouch.add(action0).add(action1).perform(); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void zoom(WebElement el) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - Dimension dimensions = el.getSize(); - Point upperLeft = el.getLocation(); - Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, - upperLeft.getY() + dimensions.getHeight() / 2); - int yOffset = center.getY() - upperLeft.getY(); - - TouchAction action0 = new TouchAction(this).press(center.getX(), center.getY()) - .moveTo(el, center.getX(), center.getY() - yOffset).release(); - TouchAction action1 = new TouchAction(this).press(center.getX(), center.getY()) - .moveTo(el, center.getX(), center.getY() + yOffset).release(); - - multiTouch.add(action0).add(action1).perform(); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - public void zoom(int x, int y) { - MultiTouchAction multiTouch = new MultiTouchAction(this); - - int scrHeight = this.manage().window().getSize().getHeight(); - int yOffset = 100; - - if (y - 100 < 0) { - yOffset = y; - } else if (y + 100 > scrHeight) { - yOffset = scrHeight - y; - } - - TouchAction action0 = new TouchAction(this).press(x, y).moveTo(0, -yOffset).release(); - TouchAction action1 = new TouchAction(this).press(x, y).moveTo(0, yOffset).release(); - - multiTouch.add(action0).add(action1).perform(); - } - @Override public WebDriver context(String name) { checkNotNull(name, "Must supply a context name"); execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); diff --git a/src/main/java/io/appium/java_client/AppiumSetting.java b/src/main/java/io/appium/java_client/AppiumSetting.java deleted file mode 100644 index c347f787f..000000000 --- a/src/main/java/io/appium/java_client/AppiumSetting.java +++ /dev/null @@ -1,38 +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; - - -/** - * This enum is deprecated. Was moved to - * {@link io.appium.java_client.Setting}. - */ -@Deprecated -public enum AppiumSetting { - - IGNORE_UNIMPORTANT_VIEWS("ignoreUnimportantViews"); - private String name; - - private AppiumSetting(String name) { - this.name = name; - } - - public String toString() { - return this.name; - } - -} diff --git a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java index 38ea729ad..085ad85a0 100644 --- a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java +++ b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java @@ -39,7 +39,7 @@ abstract class DefaultGenericMobileElement extends RemoteW implements FindsByClassName, FindsByCssSelector, FindsById, FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByFluentSelector, FindsByAccessibilityId, - ExecutesMethod, TouchableElement { + ExecutesMethod { @Override public Response execute(String driverCommand, Map parameters) { return super.execute(driverCommand, parameters); diff --git a/src/main/java/io/appium/java_client/DeviceActionShortcuts.java b/src/main/java/io/appium/java_client/DeviceActionShortcuts.java deleted file mode 100644 index 4f819d489..000000000 --- a/src/main/java/io/appium/java_client/DeviceActionShortcuts.java +++ /dev/null @@ -1,49 +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 static io.appium.java_client.MobileCommand.GET_DEVICE_TIME; -import static io.appium.java_client.MobileCommand.HIDE_KEYBOARD; - -import org.openqa.selenium.remote.Response; - -@Deprecated -/** - * This interface is deprecated and won't be supported anymore. - * Please use {@link HasDeviceTime} and {@link HidesKeyboard} API instead. - */ -public interface DeviceActionShortcuts extends ExecutesMethod { - - /** - * Hides the keyboard if it is showing. - * On iOS, there are multiple strategies for hiding the keyboard. - * Defaults to the "tapOutside" strategy (taps outside the keyboard). - * Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work. - */ - default void hideKeyboard() { - execute(HIDE_KEYBOARD); - } - - /* - Gets device date and time for both iOS(Supports only real device) and Android devices - */ - default String getDeviceTime() { - Response response = execute(GET_DEVICE_TIME); - return response.getValue().toString(); - } - -} diff --git a/src/main/java/io/appium/java_client/InteractsWithApps.java b/src/main/java/io/appium/java_client/InteractsWithApps.java index 0b6d36ac6..12a497131 100644 --- a/src/main/java/io/appium/java_client/InteractsWithApps.java +++ b/src/main/java/io/appium/java_client/InteractsWithApps.java @@ -65,19 +65,6 @@ default void resetApp() { execute(RESET); } - /** - * Runs the current app as a background app for the number of seconds - * requested. This is a synchronous method, it returns after the back has - * been returned to the foreground. - * This method is deprecated. Please use {@link #runAppInBackground(Duration)} instead. - * - * @param seconds Number of seconds to run App in background. - */ - @Deprecated - default void runAppInBackground(int seconds) { - runAppInBackground(Duration.ofSeconds(seconds)); - } - /** * Runs the current app as a background app for the time * requested. This is a synchronous method, it returns after the back has diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index 85ea4f4ff..6c6a79ac1 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -328,20 +328,6 @@ public static ImmutableMap prepareArguments(String[] params, LONG_PRESS_KEY_CODE, prepareArguments(parameters, values)); } - /** - * This method forms a {@link java.util.Map} of parameters for the - * device locking. - * The method is deprecated. Please use {@link #lockDeviceCommand(Duration)} instead. - * - * @param seconds seconds number of seconds to lock the screen for - * @return a key-value pair. The key is the command name. The value is a - * {@link java.util.Map} command arguments. - */ - @Deprecated - public static Map.Entry> lockDeviceCommand(int seconds) { - return lockDeviceCommand(Duration.ofSeconds(seconds)); - } - /** * This method forms a {@link java.util.Map} of parameters for the * device locking. diff --git a/src/main/java/io/appium/java_client/MobileElement.java b/src/main/java/io/appium/java_client/MobileElement.java index 3d7534d36..f2a98536b 100644 --- a/src/main/java/io/appium/java_client/MobileElement.java +++ b/src/main/java/io/appium/java_client/MobileElement.java @@ -42,47 +42,6 @@ public Point getCenter() { upperLeft.getY() + dimensions.getHeight() / 2); } - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - @Override public void tap(int fingers, int duration) { - AppiumDriver.class.cast(parent).tap(fingers, this, duration); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - @Override public void pinch() { - AppiumDriver.class.cast(parent).pinch(this); - } - - /** - * This method is deprecated and it is going to be removed soon. - */ - @Deprecated - @Override public void zoom() { - AppiumDriver.class.cast(parent).zoom(this); - } - - /** - * This method does nothing. It is going to be removed. - */ - @Deprecated - @Override public void swipe(SwipeElementDirection direction, int duration) { - direction.swipe(AppiumDriver.class.cast(parent), this, 0, 0, duration); - } - - /** - * This method does nothing. It is going to be removed. - */ - @Deprecated - @Override public void swipe(SwipeElementDirection direction, int offsetFromStartBorder, - int offsetFromEndBorder, int duration) throws IllegalCoordinatesException { - direction.swipe(AppiumDriver.class.cast(parent), this, offsetFromStartBorder, offsetFromEndBorder, duration); - } - @Override public List findElements(By by) { return super.findElements(by); } diff --git a/src/main/java/io/appium/java_client/SwipeElementDirection.java b/src/main/java/io/appium/java_client/SwipeElementDirection.java deleted file mode 100644 index 581b1bb58..000000000 --- a/src/main/java/io/appium/java_client/SwipeElementDirection.java +++ /dev/null @@ -1,217 +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 org.aspectj.lang.annotation.SuppressAjWarnings; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.Point; - -/** - * This enum is deprecated. It is going to be removed - */ -@Deprecated -public enum SwipeElementDirection { - /** - * Up from the center of the lower. - */ - UP { - @Override int getStartX(Point center, Point location, Dimension size, int ignored) { - return center.getX(); - } - - @Override int getStartY(Point center, Point location, Dimension size, int offSet) { - int result = location.getY() + size.getHeight() - offSet; - checkYCoordinate(result, location, size, offSet); - return result; - } - - @Override int getEndX(Point center, Point location, Dimension size, int ignored) { - return center.getX(); - } - - @Override int getEndY(Point center, Point location, Dimension size, int offSet) { - int result = location.getY() + offSet; - checkYCoordinate(result, location, size, offSet); - return result; - } - - @Override void checkDirection(int x1, int y1, int x2, int y2) { - if (y1 < y2) { - throw new IllegalCoordinatesException( - "Y1 " + y1 + " and Y2 " + y2 + " are inconsistent. It looks like you are " - + "trying to perform the swiping down"); - } - } - }, - /** - * Down from the center of the upper. - */ - DOWN { - @Override int getStartX(Point center, Point location, Dimension size, int offSet) { - return center.getX(); - } - - @Override int getStartY(Point center, Point location, Dimension size, int offSet) { - return UP.getEndY(center, location, size, offSet); - } - - @Override int getEndX(Point center, Point location, Dimension size, int offSet) { - return center.getX(); - } - - @Override int getEndY(Point center, Point location, Dimension size, int offSet) { - return UP.getStartY(center, location, size, offSet); - } - - @Override void checkDirection(int x1, int y1, int x2, int y2) { - if (y1 > y2) { - throw new IllegalCoordinatesException( - "Y1 " + y1 + " and Y2 " + y2 + " are inconsistent. It looks like you are " - + "trying to perform the swiping up"); - } - } - }, - /** - * To the left from the center of the rightmost. - */ - LEFT { - @Override int getStartX(Point center, Point location, Dimension size, int offSet) { - int result = location.getX() + size.getWidth() - offSet; - checkXCoordinate(result, location, size, offSet); - return result; - } - - @Override int getStartY(Point center, Point location, Dimension size, int offSet) { - return center.getY(); - } - - @Override int getEndX(Point center, Point location, Dimension size, int offSet) { - int result = location.getX() + offSet; - checkXCoordinate(result, location, size, offSet); - return result; - } - - @Override int getEndY(Point center, Point location, Dimension size, int offSet) { - return center.getY(); - } - - @Override void checkDirection(int x1, int y1, int x2, int y2) { - if (x1 < x2) { - throw new IllegalCoordinatesException( - "X1 " + x1 + " and X2 " + x2 + " are inconsistent. It looks like you are " - + "trying to perform the swiping right"); - } - - } - }, - /** - * To the right from the center of the leftmost. - */ - RIGHT { - @Override int getStartX(Point center, Point location, Dimension size, int offSet) { - return LEFT.getEndX(center, location, size, offSet); - } - - @Override int getStartY(Point center, Point location, Dimension size, int offSet) { - return center.getY(); - } - - @Override int getEndX(Point center, Point location, Dimension size, int offSet) { - return LEFT.getStartX(center, location, size, offSet); - } - - @Override int getEndY(Point center, Point location, Dimension size, int offSet) { - return center.getY(); - } - - @Override void checkDirection(int x1, int y1, int x2, int y2) { - if (x1 > x2) { - throw new IllegalCoordinatesException( - "X1 " + x1 + " and X2 " + x2 + " are inconsistent. It looks like you are " - + "trying to perform the swiping left"); - } - } - }; - - @SuppressAjWarnings("unused") - static void checkYCoordinate(int y, Point location, Dimension size, int offSet) - throws IllegalCoordinatesException { - int bottom = location.getY() + size.getHeight(); - int top = location.getY(); - if (y > bottom) { - throw new IllegalCoordinatesException( - "The result Y " + y + " is lower than target element bottom " + bottom); - } - if (y < top) { - throw new IllegalCoordinatesException( - "The result Y " + y + " is higher than target element top " + top); - } - - } - - @SuppressAjWarnings("unused") - static void checkXCoordinate(int x, Point location, Dimension size, int offSet) - throws IllegalCoordinatesException { - int right = location.getX() + size.getWidth(); - int left = location.getX(); - if (x > right) { - throw new IllegalCoordinatesException( - "The result X " + x + " is righter than target element right border " + right); - } - if (x < left) { - throw new IllegalCoordinatesException( - "The result X " + x + " is lefter than target element left border " + left); - } - - } - - abstract int getStartX(Point center, Point location, Dimension size, int offSet); - - abstract int getStartY(Point center, Point location, Dimension size, int offSet); - - abstract int getEndX(Point center, Point location, Dimension size, int offSet); - - abstract int getEndY(Point center, Point location, Dimension size, int offSet); - - abstract void checkDirection(int x1, int y1, int x2, int y2); - - /** - * Creates the swiping action. It is supposed to be performed inside the given element. - * The method is deprecated and has no effect. - * - * @param driver an instance that extends {@link AppiumDriver} - * @param element the element that is going to be swiped - * @param offset1 from the first (starting) element board - * @param offset2 from the ending element board - * @param duration in milliseconds - * @throws IllegalCoordinatesException when starting/ending coordinates are outside of the given element - */ - @Deprecated - public void swipe(AppiumDriver driver, MobileElement element, int offset1, int offset2, - int duration) throws IllegalCoordinatesException { - Point p = element.getCenter(); - Point location = element.getLocation(); - Dimension size = element.getSize(); - int startX = getStartX(p, location, size, offset1); - int startY = getStartY(p, location, size, offset1); - int endX = getEndX(p, location, size, offset2); - int endY = getEndY(p, location, size, offset2); - checkDirection(startX, startY, endX, endY); - - driver.swipe(startX, startY, endX, endY, duration); - } -} diff --git a/src/main/java/io/appium/java_client/TouchAction.java b/src/main/java/io/appium/java_client/TouchAction.java index 6150d1bcf..e05d8effd 100644 --- a/src/main/java/io/appium/java_client/TouchAction.java +++ b/src/main/java/io/appium/java_client/TouchAction.java @@ -197,18 +197,6 @@ public TouchAction waitAction() { return this; } - /** - * Waits for specified amount of time to pass before continue to next touch action. - * The method is deprecated. Please use {@link #waitAction(Duration)} instead. - * - * @param ms time in milliseconds to wait. - * @return this TouchAction, for chaining. - */ - @Deprecated - public TouchAction waitAction(int ms) { - return waitAction(Duration.ofMillis(ms)); - } - /** * Waits for specified amount of time to pass before continue to next touch action. * @@ -234,19 +222,6 @@ public TouchAction longPress(WebElement el) { return this; } - /** - * Press and hold the at the center of an element until the contextmenu event has fired. - * This method is deprecated. Please use {@link #longPress(WebElement, Duration)} instead. - * - * @param el element to long-press. - * @param duration of the long-press, in milliseconds. - * @return this TouchAction, for chaining. - */ - @Deprecated - public TouchAction longPress(WebElement el, int duration) { - return longPress(el, Duration.ofMillis(duration)); - } - /** * Press and hold the at the center of an element until the contextmenu event has fired. * @@ -277,21 +252,6 @@ public TouchAction longPress(int x, int y) { return this; } - /** - * Press and hold the at an absolute position on the screen until the - * contextmenu event has fired. - * The method is deprecated. Please use {@link #longPress(int, int, Duration)} instead. - * - * @param x x coordinate. - * @param y y coordinate. - * @param duration of the long-press, in milliseconds. - * @return this TouchAction, for chaining. - */ - @Deprecated - public TouchAction longPress(int x, int y, int duration) { - return longPress(x, y, Duration.ofMillis(duration)); - } - /** * Press and hold the at an absolute position on the screen until the * contextmenu event has fired. @@ -328,22 +288,6 @@ public TouchAction longPress(WebElement el, int x, int y) { return this; } - /** - * Press and hold the at an elements upper-left corner, offset by the - * given amount, until the contextmenu event has fired. - * The method is deprecated. Please use {@link #longPress(WebElement, int, int, Duration)} instead. - * - * @param el element to long-press. - * @param x x offset. - * @param y y offset. - * @param duration of the long-press, in milliseconds. - * @return this TouchAction, for chaining. - */ - @Deprecated - public TouchAction longPress(WebElement el, int x, int y, int duration) { - return longPress(el, x, y, Duration.ofMillis(duration)); - } - /** * Press and hold the at an elements upper-left corner, offset by the * given amount, until the contextmenu event has fired. diff --git a/src/main/java/io/appium/java_client/TouchableElement.java b/src/main/java/io/appium/java_client/TouchableElement.java deleted file mode 100644 index d7c64ee4d..000000000 --- a/src/main/java/io/appium/java_client/TouchableElement.java +++ /dev/null @@ -1,123 +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 org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.FindsByClassName; -import org.openqa.selenium.internal.FindsByCssSelector; -import org.openqa.selenium.internal.FindsById; -import org.openqa.selenium.internal.FindsByLinkText; -import org.openqa.selenium.internal.FindsByName; -import org.openqa.selenium.internal.FindsByTagName; -import org.openqa.selenium.internal.FindsByXPath; - -import java.util.List; - -@Deprecated -/** - * This API is deprecated and it is going to be removed. - */ -public interface TouchableElement extends WebElement, FindsByClassName, - FindsByCssSelector, FindsById, - FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByFluentSelector, FindsByAccessibilityId, - ExecutesMethod { - - List findElements(By by); - - T findElement(By by); - - T findElementByClassName(String className); - - List findElementsByClassName(String className); - - T findElementByCssSelector(String cssSelector); - - List findElementsByCssSelector(String cssSelector); - - T findElementById(String id); - - List findElementsById(String id); - - T findElementByLinkText(String linkText); - - List findElementsByLinkText(String linkText); - - T findElementByPartialLinkText(String partialLinkText); - - List findElementsByPartialLinkText(String partialLinkText); - - T findElementByName(String name); - - List findElementsByName(String name); - - T findElementByTagName(String tagName); - - List findElementsByTagName(String tagName); - - T findElementByXPath(String xPath); - - List findElementsByXPath(String xPath); - - /** - * Convenience method for pinching the given element. - * "pinching" refers to the action of two appendages pressing the screen - * and sliding towards each other. - * NOTE: - * This convenience method places the initial touches around the element, - * if this would happen to place one of them off the screen, appium with return an - * outOfBounds error. In this case, revert to using the MultiTouchAction api - * instead of this method. - */ - void pinch(); - - /** - * Convenience method for tapping the center of the given element. - * - * @param fingers number of fingers/appendages to tap with. - * @param duration how long between pressing down, and lifting fingers/appendages. - */ - void tap(int fingers, int duration); - - /** - * Convenience method for "zooming in" on the given element. - * "zooming in" refers to the action of two appendages pressing the screen and - * sliding away from each other. - * NOTE: - * This convenience method slides touches away from the element, if this would happen to - * place one of them off the screen, appium will return an outOfBounds error. - * In this case, revert to using the MultiTouchAction api instead of this method. - */ - void zoom(); - - - /** - * This method does nothing. It is going to be removed. - */ - @Deprecated - void swipe(SwipeElementDirection direction, int duration); - - - @Deprecated - /** - * This method is deprecated and it is going to be removed. - * Please use the {@link CreatesSwipeAction#swipe(WebElement, SwipeElementDirection, int, int, int)} - * instead. - */ - void swipe(SwipeElementDirection direction, int offsetFromStartBorder, int offsetFromEndBorder, - int duration) throws IllegalCoordinatesException; -} \ No newline at end of file diff --git a/src/main/java/io/appium/java_client/android/AndroidDeviceActionShortcuts.java b/src/main/java/io/appium/java_client/android/AndroidDeviceActionShortcuts.java deleted file mode 100644 index 4fa8eb101..000000000 --- a/src/main/java/io/appium/java_client/android/AndroidDeviceActionShortcuts.java +++ /dev/null @@ -1,75 +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 static io.appium.java_client.android.AndroidMobileCommandHelper.longPressKeyCodeCommand; -import static io.appium.java_client.android.AndroidMobileCommandHelper.pressKeyCodeCommand; - -import io.appium.java_client.CommandExecutionHelper; -import io.appium.java_client.DeviceActionShortcuts; - -@Deprecated -/** - * This interface is deprecated and won't be supported anymore. - * Please use {@link io.appium.java_client.PressesKeyCode} API instead - */ -public interface AndroidDeviceActionShortcuts extends DeviceActionShortcuts { - - /** - * Send a key event to the device. - * - * @param key code for the key pressed on the device. - */ - default void pressKeyCode(int key) { - CommandExecutionHelper.execute(this, pressKeyCodeCommand(key)); - } - - /** - * Send a key event along with an Android metastate to an Android device. - * Metastates are things like *shift* to get uppercase characters. - * - * @param key code for the key pressed on the Android device. - * @param metastate metastate for the keypress. - * @see AndroidKeyCode - * @see AndroidKeyMetastate - */ - default void pressKeyCode(int key, Integer metastate) { - CommandExecutionHelper.execute(this, pressKeyCodeCommand(key, metastate)); - } - - /** - * Send a long key event to the device. - * - * @param key code for the key pressed on the device. - */ - default void longPressKeyCode(int key) { - CommandExecutionHelper.execute(this, longPressKeyCodeCommand(key)); - } - - /** - * Send a long key event along with an Android metastate to an Android device. - * Metastates are things like *shift* to get uppercase characters. - * - * @param key code for the key pressed on the Android device. - * @param metastate metastate for the keypress. - * @see AndroidKeyCode - * @see AndroidKeyMetastate - */ - default void longPressKeyCode(int key, Integer metastate) { - CommandExecutionHelper.execute(this, longPressKeyCodeCommand(key, metastate)); - } -} 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 46c770093..424a9bec5 100644 --- a/src/main/java/io/appium/java_client/android/AndroidDriver.java +++ b/src/main/java/io/appium/java_client/android/AndroidDriver.java @@ -24,7 +24,6 @@ import io.appium.java_client.CommandExecutionHelper; import io.appium.java_client.FindsByAndroidUIAutomator; import io.appium.java_client.PressesKeyCode; -import io.appium.java_client.TouchAction; import io.appium.java_client.remote.AppiumCommandExecutor; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.service.local.AppiumDriverLocalService; @@ -153,13 +152,6 @@ public AndroidDriver(Capabilities desiredCapabilities) { super(substituteMobilePlatform(desiredCapabilities, ANDROID_PLATFORM)); } - /** - * This method is deprecated. It is going to be removed - */ - @Override public void swipe(int startx, int starty, int endx, int endy, int duration) { - new TouchAction(this).press(startx, starty).waitAction(duration).moveTo(endx, endy).release().perform(); - } - /** * Get test-coverage data. * diff --git a/src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java b/src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java index d00930eaa..951fa3f1a 100644 --- a/src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java @@ -172,49 +172,6 @@ public class AndroidMobileCommandHelper extends MobileCommand { IS_LOCKED, ImmutableMap.of()); } - - /** - * It is deprecated. Please use {@link MobileCommand#pressKeyCodeCommand(int)} instead. - */ - @Deprecated - public static Map.Entry> pressKeyCodeCommand(int key) { - return new AbstractMap.SimpleEntry<>( - PRESS_KEY_CODE, prepareArguments("keycode", key)); - } - - /** - * It is deprecated. Please use {@link MobileCommand#pressKeyCodeCommand(int, Integer)} instead. - */ - @Deprecated - public static Map.Entry> pressKeyCodeCommand(int key, - Integer metastate) { - String[] parameters = new String[] {"keycode", "metastate"}; - Object[] values = new Object[] {key, metastate}; - return new AbstractMap.SimpleEntry<>( - PRESS_KEY_CODE, prepareArguments(parameters, values)); - } - - /** - * It is deprecated. Please use {@link MobileCommand#longPressKeyCodeCommand(int)} instead. - */ - @Deprecated - public static Map.Entry> longPressKeyCodeCommand(int key) { - return new AbstractMap.SimpleEntry<>( - LONG_PRESS_KEY_CODE, prepareArguments("keycode", key)); - } - - /** - * It is deprecated. Please use {@link MobileCommand#longPressKeyCodeCommand(int, Integer)} instead. - */ - @Deprecated - public static Map.Entry> longPressKeyCodeCommand(int key, - Integer metastate) { - String[] parameters = new String[] {"keycode", "metastate"}; - Object[] values = new Object[] {key, metastate}; - return new AbstractMap.SimpleEntry<>( - LONG_PRESS_KEY_CODE, prepareArguments(parameters, values)); - } - /** * This method forms a {@link java.util.Map} of parameters for the * notification opening. @@ -329,13 +286,6 @@ public class AndroidMobileCommandHelper extends MobileCommand { return new AbstractMap.SimpleEntry<>(UNLOCK, ImmutableMap.of()); } - /** - * This method was moved to {@link MobileCommand#hideKeyboardCommand(String, String)}. - */ - @Deprecated - public static Map.Entry> lockDeviceCommand() { - return new AbstractMap.SimpleEntry<>(LOCK, prepareArguments("seconds", 0)); - } /** * This method forms a {@link java.util.Map} of parameters for the element diff --git a/src/main/java/io/appium/java_client/android/HasAndroidSettings.java b/src/main/java/io/appium/java_client/android/HasAndroidSettings.java index 4550c8a4f..220dfcb48 100644 --- a/src/main/java/io/appium/java_client/android/HasAndroidSettings.java +++ b/src/main/java/io/appium/java_client/android/HasAndroidSettings.java @@ -36,17 +36,6 @@ default void ignoreUnimportantViews(Boolean compress) { setSetting(Setting.IGNORE_UNIMPORTANT_VIEWS, compress); } - /** - * invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator} - * This method is deprecated. Please use {@link #configuratorSetWaitForIdleTimeout(Duration)} instead. - * - * @param timeout in milliseconds. A negative value would reset to its default value - */ - @Deprecated - default void configuratorSetWaitForIdleTimeout(int timeout) { - configuratorSetWaitForIdleTimeout(Duration.ofMillis(timeout)); - } - /** * invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator} * @@ -57,17 +46,6 @@ default void configuratorSetWaitForIdleTimeout(Duration timeout) { setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, timeout.toMillis()); } - /** - * invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator} - * This method is deprecated. Please use {@link #configuratorSetWaitForSelectorTimeout(Duration)} instead. - * - * @param timeout in milliseconds. A negative value would reset to its default value - */ - @Deprecated - default void configuratorSetWaitForSelectorTimeout(int timeout) { - configuratorSetWaitForSelectorTimeout(Duration.ofMillis(timeout)); - } - /** * invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator} * @@ -78,17 +56,6 @@ default void configuratorSetWaitForSelectorTimeout(Duration timeout) { setSetting(Setting.WAIT_FOR_SELECTOR_TIMEOUT, timeout.toMillis()); } - /** - * invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} - * This method is deprecated. Please use {@link #configuratorSetScrollAcknowledgmentTimeout(Duration)} instead. - * - * @param timeout in milliseconds. A negative value would reset to its default value - */ - @Deprecated - default void configuratorSetScrollAcknowledgmentTimeout(int timeout) { - configuratorSetScrollAcknowledgmentTimeout(Duration.ofMillis(timeout)); - } - /** * invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} * @@ -99,17 +66,6 @@ default void configuratorSetScrollAcknowledgmentTimeout(Duration timeout) { setSetting(Setting.WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT, timeout.toMillis()); } - /** - * invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator} - * This method is deprecated. Please use {@link #configuratorSetKeyInjectionDelay(Duration)} instead. - * - * @param delay in milliseconds. A negative value would reset to its default value - */ - @Deprecated - default void configuratorSetKeyInjectionDelay(int delay) { - configuratorSetKeyInjectionDelay(Duration.ofMillis(delay)); - } - /** * invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator} * @@ -120,17 +76,6 @@ default void configuratorSetKeyInjectionDelay(Duration delay) { setSetting(Setting.KEY_INJECTION_DELAY, delay.toMillis()); } - /** - * invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} - * This method is deprecated. Please use {@link #configuratorSetActionAcknowledgmentTimeout(Duration)} instead. - * - * @param timeout in milliseconds. A negative value would reset to its default value - */ - @Deprecated - default void configuratorSetActionAcknowledgmentTimeout(int timeout) { - configuratorSetActionAcknowledgmentTimeout(Duration.ofMillis(timeout)); - } - /** * invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator} * diff --git a/src/main/java/io/appium/java_client/android/LocksAndroidDevice.java b/src/main/java/io/appium/java_client/android/LocksAndroidDevice.java index c97d59123..f5b46d00e 100644 --- a/src/main/java/io/appium/java_client/android/LocksAndroidDevice.java +++ b/src/main/java/io/appium/java_client/android/LocksAndroidDevice.java @@ -19,10 +19,13 @@ import static io.appium.java_client.MobileCommand.lockDeviceCommand; import static io.appium.java_client.android.AndroidMobileCommandHelper.isLockedCommand; import static io.appium.java_client.android.AndroidMobileCommandHelper.unlockCommand; +import static java.time.Duration.ofMillis; import io.appium.java_client.CommandExecutionHelper; import io.appium.java_client.ExecutesMethod; +import java.time.Duration; + public interface LocksAndroidDevice extends ExecutesMethod { /** * Check if the device is locked. @@ -37,7 +40,7 @@ default boolean isLocked() { * This method locks a device. */ default void lockDevice() { - CommandExecutionHelper.execute(this, lockDeviceCommand(0)); + CommandExecutionHelper.execute(this, lockDeviceCommand(ofMillis(0))); } /** diff --git a/src/main/java/io/appium/java_client/android/StartsActivity.java b/src/main/java/io/appium/java_client/android/StartsActivity.java index 05b31603c..ca95733ff 100644 --- a/src/main/java/io/appium/java_client/android/StartsActivity.java +++ b/src/main/java/io/appium/java_client/android/StartsActivity.java @@ -48,108 +48,6 @@ default void startActivity(Activity activity) { activity.getOptionalIntentArguments(), activity.isStopApp())); } - /** - * This method should start arbitrary activity during a test. If the activity belongs to - * another application, that application is started and the activity is opened. - * - * @param appPackage The package containing the activity. [Required] - * @param appActivity The activity to start. [Required] - * @param appWaitPackage Automation will begin after this package starts. [Optional] - * @param appWaitActivity Automation will begin after this activity starts. [Optional] - * @param stopApp If true, target app will be stopped. [Optional] - * @deprecated Instead use {@link #startActivity(Activity)} - */ - @Deprecated - default void startActivity(String appPackage, String appActivity, String appWaitPackage, - String appWaitActivity, boolean stopApp) throws IllegalArgumentException { - this.startActivity(appPackage,appActivity,appWaitPackage, - appWaitActivity,null,null,null,null,stopApp); - } - - /** - * This method should start arbitrary activity during a test. If the activity belongs to - * another application, that application is started and the activity is opened. - * - * @param appPackage The package containing the activity. [Required] - * @param appActivity The activity to start. [Required] - * @param appWaitPackage Automation will begin after this package starts. [Optional] - * @param appWaitActivity Automation will begin after this activity starts. [Optional] - * @deprecated Instead use {@link #startActivity(Activity)} - */ - @Deprecated - default void startActivity(String appPackage, String appActivity, String appWaitPackage, - String appWaitActivity) throws IllegalArgumentException { - this.startActivity(appPackage, appActivity, - appWaitPackage, appWaitActivity,null,null,null,null,true); - } - - /** - * This method should start arbitrary activity during a test. If the activity belongs to - * another application, that application is started and the activity is opened. - * - * @param appPackage The package containing the activity. [Required] - * @param appActivity The activity to start. [Required] - * @deprecated Instead use {@link #startActivity(Activity)} - */ - @Deprecated - default void startActivity(String appPackage, String appActivity) throws IllegalArgumentException { - this.startActivity(appPackage, appActivity, null, null, - null,null,null,null,true); - } - - /** - * This method should start arbitrary activity during a test. If the activity belongs to - * another application, that application is started and the activity is opened. - * - * @param appPackage The package containing the activity. [Required] - * @param appActivity The activity to start. [Required] - * @param appWaitPackage Automation will begin after this package starts. [Optional] - * @param appWaitActivity Automation will begin after this activity starts. [Optional] - * @param intentAction Intent action which will be used to start activity [Optional] - * @param intentCategory Intent category which will be used to start activity [Optional] - * @param intentFlags Flags that will be used to start activity [Optional] - * @param intentOptionalArgs Additional intent arguments that will be used to - * start activity [Optional] - * @deprecated Instead use {@link #startActivity(Activity)} - */ - @Deprecated - default void startActivity(String appPackage, String appActivity, - String appWaitPackage, String appWaitActivity, - String intentAction, String intentCategory, - String intentFlags, String intentOptionalArgs) - throws IllegalArgumentException { - this.startActivity(appPackage,appActivity, - appWaitPackage,appWaitActivity, - intentAction,intentCategory,intentFlags,intentOptionalArgs,true); - } - - /** - * This method should start arbitrary activity during a test. If the activity belongs to - * another application, that application is started and the activity is opened. - * - * @param appPackage The package containing the activity. [Required] - * @param appActivity The activity to start. [Required] - * @param appWaitPackage Automation will begin after this package starts. [Optional] - * @param appWaitActivity Automation will begin after this activity starts. [Optional] - * @param intentAction Intent action which will be used to start activity [Optional] - * @param intentCategory Intent category which will be used to start activity [Optional] - * @param intentFlags Flags that will be used to start activity [Optional] - * @param optionalIntentArguments Additional intent arguments that will be used to - * start activity [Optional] - * @param stopApp If true, target app will be stopped. [Optional] - * @deprecated Instead use {@link #startActivity(Activity)} - */ - @Deprecated - default void startActivity(String appPackage, String appActivity, String appWaitPackage, - String appWaitActivity, String intentAction, - String intentCategory, String intentFlags, - String optionalIntentArguments,boolean stopApp ) - throws IllegalArgumentException { - CommandExecutionHelper.execute(this, startActivityCommand(appPackage, appActivity, - appWaitPackage, appWaitActivity, intentAction, intentCategory, intentFlags, - optionalIntentArguments, stopApp)); - } - /** * Get the current activity being run on the mobile device. * diff --git a/src/main/java/io/appium/java_client/android/internal/JsonToAndroidElementConverter.java b/src/main/java/io/appium/java_client/android/internal/JsonToAndroidElementConverter.java deleted file mode 100644 index 7196065dd..000000000 --- a/src/main/java/io/appium/java_client/android/internal/JsonToAndroidElementConverter.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.android.internal; - -import io.appium.java_client.MobileElement; -import io.appium.java_client.android.AndroidElement; -import io.appium.java_client.internal.JsonToMobileElementConverter; -import org.openqa.selenium.remote.RemoteWebDriver; - -/** - * It is never used now. Please use {@link io.appium.java_client.internal.JsonToMobileElementConverter} - * instead - */ -@Deprecated -public class JsonToAndroidElementConverter extends JsonToMobileElementConverter { - - public JsonToAndroidElementConverter(RemoteWebDriver driver) { - super(driver, null); - } - - @Override protected MobileElement newMobileElement() { - AndroidElement toReturn = new AndroidElement(); - toReturn.setParent(driver); - return toReturn; - } - -} diff --git a/src/main/java/io/appium/java_client/internal/ElementMap.java b/src/main/java/io/appium/java_client/internal/ElementMap.java index 9435a7e7d..0dec31b3e 100644 --- a/src/main/java/io/appium/java_client/internal/ElementMap.java +++ b/src/main/java/io/appium/java_client/internal/ElementMap.java @@ -25,7 +25,6 @@ import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.windows.WindowsElement; -import io.appium.java_client.youiengine.YouiEngineElement; import org.openqa.selenium.remote.RemoteWebElement; import java.util.Map; @@ -34,7 +33,6 @@ public enum ElementMap { ANDROID_UIAUTOMATOR2(AutomationName.ANDROID_UIAUTOMATOR2.toLowerCase(), AndroidElement.class), SELENDROID(AutomationName.SELENDROID.toLowerCase(), AndroidElement.class), - YOUI_ENGINE(AutomationName.YOUI_ENGINE.toLowerCase(), YouiEngineElement.class), IOS_XCUI_TEST(AutomationName.IOS_XCUI_TEST.toLowerCase(), IOSElement.class), ANDROID_UI_AUTOMATOR(MobilePlatform.ANDROID.toLowerCase(), AndroidElement.class), IOS_UI_AUTOMATION(MobilePlatform.IOS.toLowerCase(), IOSElement.class), diff --git a/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java b/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java deleted file mode 100644 index 122b25f14..000000000 --- a/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.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 static io.appium.java_client.ios.IOSMobileCommandHelper.hideKeyboardCommand; -import static io.appium.java_client.ios.IOSMobileCommandHelper.shakeCommand; - -import io.appium.java_client.CommandExecutionHelper; -import io.appium.java_client.DeviceActionShortcuts; - -@Deprecated -/** - * This interface is deprecated and won't be supported anymore. - * Please use {@link io.appium.java_client.HidesKeyboardWithKeyName} and {@link ShakesDevice} API instead. - */ -public interface IOSDeviceActionShortcuts extends DeviceActionShortcuts { - - /** - * Hides the keyboard by pressing the button specified by keyName if it is - * showing. - * - * @param keyName The button pressed by the mobile driver to attempt hiding the - * keyboard. - */ - default void hideKeyboard(String keyName) { - CommandExecutionHelper.execute(this, hideKeyboardCommand(keyName)); - } - - /** - * Hides the keyboard if it is showing. Available strategies are PRESS_KEY - * and TAP_OUTSIDE. One taps outside the keyboard, the other presses a key - * of your choosing (probably the 'Done' key). Hiding the keyboard often - * depends on the way an app is implemented, no single strategy always - * works. - * - * @param strategy HideKeyboardStrategy. - * @param keyName a String, representing the text displayed on the button of the - * keyboard you want to press. For example: "Done". - */ - default void hideKeyboard(String strategy, String keyName) { - CommandExecutionHelper.execute(this, hideKeyboardCommand(strategy, keyName)); - } - - /** - * Simulate shaking the device. - */ - default void shake() { - CommandExecutionHelper.execute(this, shakeCommand()); - } - -} 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 394b09ab4..0394264d8 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -24,7 +24,6 @@ import io.appium.java_client.FindsByIosNSPredicate; import io.appium.java_client.FindsByIosUIAutomation; import io.appium.java_client.HidesKeyboardWithKeyName; -import io.appium.java_client.TouchAction; import io.appium.java_client.remote.AppiumCommandExecutor; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.service.local.AppiumDriverLocalService; @@ -38,6 +37,7 @@ import org.openqa.selenium.security.Credentials; import java.net.URL; +import java.time.Duration; /** * @param the required type of class which implement @@ -158,31 +158,17 @@ public IOSDriver(Capabilities desiredCapabilities) { super(substituteMobilePlatform(desiredCapabilities, IOS_PLATFORM)); } - /** - * This method is deprecated. It is going to be removed - */ - @Override public void swipe(int startx, int starty, int endx, int endy, int duration) { - int xOffset = endx - startx; - int yOffset = endy - starty; - new TouchAction(this).press(startx, starty).waitAction(duration).moveTo(xOffset, yOffset).release().perform(); - } - /** * Runs the current app as a background app for the number of seconds * or minimizes the app * - * @param seconds if seconds >= 0: Number of seconds to run App in background. - * This method call will block main thread and restore the application under - * test after the timeout expires. - * if seconds < 0: any negative number of seconds will put the application - * under test into background and return immediately, so iOS dashboard - * will remain on-screen (this, actually, simulates click on Home button) + * @param duration The time to run App in background. */ - @Override public void runAppInBackground(int seconds) { + @Override public void runAppInBackground(Duration duration) { // timeout parameter is expected to be in milliseconds // float values are allowed execute(RUN_APP_IN_BACKGROUND, - prepareArguments("seconds", prepareArguments("timeout", seconds * 1000))); + prepareArguments("seconds", prepareArguments("timeout", duration.toMillis()))); } @Override public TargetLocator switchTo() { diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java index 74a0a6f52..9f4af73e3 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java @@ -25,36 +25,6 @@ public class IOSMobileCommandHelper extends MobileCommand { - /** - * This method was moved to {@link MobileCommand#hideKeyboardCommand(String)}. - */ - @Deprecated - public static Map.Entry> hideKeyboardCommand(String keyName) { - return new AbstractMap.SimpleEntry<>( - HIDE_KEYBOARD, prepareArguments("keyName", keyName)); - } - - /** - * This method was moved to {@link MobileCommand#hideKeyboardCommand(String, String)}. - */ - @Deprecated - public static Map.Entry> hideKeyboardCommand(String strategy, - String keyName) { - String[] parameters = new String[] {"strategy", "key"}; - Object[] values = new Object[] {strategy, keyName}; - return new AbstractMap.SimpleEntry<>( - HIDE_KEYBOARD, prepareArguments(parameters, values)); - } - - /** - * This method was moved to {@link MobileCommand#lockDeviceCommand(int)}. - */ - @Deprecated - public static Map.Entry> lockDeviceCommand(int seconds) { - return new AbstractMap.SimpleEntry<>( - LOCK, prepareArguments("seconds", seconds)); - } - /** * This method forms a {@link java.util.Map} of parameters for the * device shaking. diff --git a/src/main/java/io/appium/java_client/ios/LocksIOSDevice.java b/src/main/java/io/appium/java_client/ios/LocksIOSDevice.java index 558364881..007c03c73 100644 --- a/src/main/java/io/appium/java_client/ios/LocksIOSDevice.java +++ b/src/main/java/io/appium/java_client/ios/LocksIOSDevice.java @@ -24,17 +24,6 @@ import java.time.Duration; public interface LocksIOSDevice extends ExecutesMethod { - /** - * Lock the device (bring it to the lock screen) for a given number of - * seconds. - * Thsi method is deprecated. Please use {@link #lockDevice(Duration)} instead. - * - * @param seconds number of seconds to lock the screen for - */ - @Deprecated - default void lockDevice(int seconds) { - lockDevice(Duration.ofSeconds(seconds)); - } /** * Lock the device (bring it to the lock screen) for a given number of diff --git a/src/main/java/io/appium/java_client/ios/internal/JsonToIOSElementConverter.java b/src/main/java/io/appium/java_client/ios/internal/JsonToIOSElementConverter.java deleted file mode 100644 index d88b01779..000000000 --- a/src/main/java/io/appium/java_client/ios/internal/JsonToIOSElementConverter.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.ios.internal; - -import io.appium.java_client.MobileElement; -import io.appium.java_client.internal.JsonToMobileElementConverter; -import io.appium.java_client.ios.IOSElement; -import org.openqa.selenium.remote.RemoteWebDriver; - -/** - * It is never used now. Please use {@link io.appium.java_client.internal.JsonToMobileElementConverter} - * instead - */ -@Deprecated -public class JsonToIOSElementConverter extends JsonToMobileElementConverter { - - public JsonToIOSElementConverter(RemoteWebDriver driver) { - super(driver, null); - } - - @Override protected MobileElement newMobileElement() { - IOSElement toReturn = new IOSElement(); - toReturn.setParent(driver); - return toReturn; - } - -} diff --git a/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java b/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java index 0f7f39907..bc866a6aa 100644 --- a/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java +++ b/src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java @@ -25,7 +25,6 @@ import io.appium.java_client.HasSessionDetails; import io.appium.java_client.MobileElement; -import io.appium.java_client.TouchableElement; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.ios.IOSElement; import io.appium.java_client.pagefactory.bys.ContentType; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; /** * Default decorator for use with PageFactory. Will decorate 1) all of the @@ -62,7 +60,7 @@ public class AppiumFieldDecorator implements FieldDecorator { private static final List> availableElementClasses = ImmutableList.of(WebElement.class, - RemoteWebElement.class, MobileElement.class, TouchableElement.class, AndroidElement.class, + RemoteWebElement.class, MobileElement.class, AndroidElement.class, IOSElement.class, WindowsElement.class); public static long DEFAULT_IMPLICITLY_WAIT_TIMEOUT = 1; public static TimeUnit DEFAULT_TIMEUNIT = TimeUnit.SECONDS; diff --git a/src/main/java/io/appium/java_client/youiengine/YouiEngineDriver.java b/src/main/java/io/appium/java_client/youiengine/YouiEngineDriver.java deleted file mode 100644 index effa2ca85..000000000 --- a/src/main/java/io/appium/java_client/youiengine/YouiEngineDriver.java +++ /dev/null @@ -1,46 +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.youiengine; - -import io.appium.java_client.AppiumDriver; -import io.appium.java_client.TouchAction; -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.WebElement; - -import java.net.URL; - -/** - * This class is going to be removed. - * Please use {@link AppiumDriver} instead - */ -@Deprecated -public class YouiEngineDriver extends AppiumDriver { - - /** Constructor takes in the Appium Server URL and the capabilities you want to use for this - * test execution. **/ - public YouiEngineDriver(URL remoteAddress, Capabilities desiredCapabilities) { - super(remoteAddress, desiredCapabilities); - } - - @Override - public void swipe(int startx, int starty, int endx, int endy, int duration) { - // YouiEngine does not use duration - TouchAction swipeAction = new TouchAction(this).press(startx, starty).moveTo(endx, endy) - .release(); - swipeAction.perform(); - } -} diff --git a/src/main/java/io/appium/java_client/youiengine/YouiEngineElement.java b/src/main/java/io/appium/java_client/youiengine/YouiEngineElement.java deleted file mode 100644 index b25722bed..000000000 --- a/src/main/java/io/appium/java_client/youiengine/YouiEngineElement.java +++ /dev/null @@ -1,29 +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.youiengine; - -import io.appium.java_client.MobileElement; - -/** - * This class is going to be removed. - * Please use any convenient {@link MobileElement} subclass or - * {@link org.openqa.selenium.remote.RemoteWebElement} instead. - */ -@Deprecated -public class YouiEngineElement extends MobileElement { - -} diff --git a/src/main/java/io/appium/java_client/youiengine/internal/JsonToYouiEngineElementConverter.java b/src/main/java/io/appium/java_client/youiengine/internal/JsonToYouiEngineElementConverter.java deleted file mode 100644 index c1071c57c..000000000 --- a/src/main/java/io/appium/java_client/youiengine/internal/JsonToYouiEngineElementConverter.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.youiengine.internal; - -import io.appium.java_client.MobileElement; -import io.appium.java_client.internal.JsonToMobileElementConverter; -import io.appium.java_client.youiengine.YouiEngineElement; - -import org.openqa.selenium.remote.RemoteWebDriver; - -/** - * It is never used now. Please use {@link io.appium.java_client.internal.JsonToMobileElementConverter} - * instead - */ -@Deprecated -public class JsonToYouiEngineElementConverter extends JsonToMobileElementConverter { - public JsonToYouiEngineElementConverter(RemoteWebDriver driver) { - super(driver, null); - } - - @Override - protected MobileElement newMobileElement() { - YouiEngineElement toReturn = new YouiEngineElement(); - toReturn.setParent(driver); - return toReturn; - } -} - diff --git a/src/test/java/io/appium/java_client/android/AndroidDriverTest.java b/src/test/java/io/appium/java_client/android/AndroidDriverTest.java index 28d40bd39..6956ebd9c 100644 --- a/src/test/java/io/appium/java_client/android/AndroidDriverTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidDriverTest.java @@ -166,18 +166,16 @@ public class AndroidDriverTest extends BaseAndroidTest { } @Test public void getPerformanceDataTest() throws Exception { - driver.startActivity("io.appium.android.apis", ".ApiDemos"); + driver.startActivity(new Activity("io.appium.android.apis", ".ApiDemos")); List supportedPerformanceDataTypes = driver.getSupportedPerformanceDataTypes(); - for (int i = 0 ; i < supportedPerformanceDataTypes.size() ; ++ i) { - - String dataType = supportedPerformanceDataTypes.get(i); + for (String dataType : supportedPerformanceDataTypes) { List> valueTable = driver.getPerformanceData("com.example.android.apis", dataType, 60000); - for ( int j = 1 ; j < valueTable.size() ; ++ j) { - assertEquals(valueTable.subList(0,0).size(), valueTable.subList(j, j).size()); + for (int j = 1; j < valueTable.size(); ++j) { + assertEquals(valueTable.subList(0, 0).size(), valueTable.subList(j, j).size()); } } 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 36154b45b..f6062b543 100644 --- a/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java +++ b/src/test/java/io/appium/java_client/ios/XCUIAutomationTest.java @@ -28,6 +28,8 @@ import org.junit.Test; import org.openqa.selenium.DeviceRotation; +import java.time.Duration; + public class XCUIAutomationTest extends AppXCUITTest { @After public void afterMethod() { @@ -58,13 +60,13 @@ public class XCUIAutomationTest extends AppXCUITTest { @Test public void testPutIntoBackgroundAndRestore() { final long msStarted = System.currentTimeMillis(); - driver.runAppInBackground(4); + driver.runAppInBackground(Duration.ofSeconds(4)); assertThat(System.currentTimeMillis() - msStarted, greaterThan(3000L)); } @Test public void testPutIntoBackgroundWithoutRestore() { assertThat(driver.findElementsById("IntegerA"), is(not(empty()))); - driver.runAppInBackground(-1); + driver.runAppInBackground(Duration.ofSeconds(-1)); assertThat(driver.findElementsById("IntegerA"), is(empty())); }