diff --git a/src/main/java/io/appium/java_client/InteractsWithApps.java b/src/main/java/io/appium/java_client/InteractsWithApps.java index f0624db4a..202360e22 100644 --- a/src/main/java/io/appium/java_client/InteractsWithApps.java +++ b/src/main/java/io/appium/java_client/InteractsWithApps.java @@ -95,13 +95,14 @@ default void resetApp() { /** * Runs the current app as a background app for the time - * requested. This is a synchronous method, it returns after the back has - * been returned to the foreground. + * requested. This is a synchronous method, it blocks while the + * application is in background. * - * @param duration The time to run App in background. Minimum time resolution is one second + * @param duration The time to run App in background. Minimum time resolution is one millisecond. + * Passing zero or a negative value will switch to Home screen and return immediately. */ default void runAppInBackground(Duration duration) { - execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.getSeconds())); + execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0)); } /** 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 1d668c5de..229aac70b 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -16,7 +16,6 @@ package io.appium.java_client.ios; -import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND; import static io.appium.java_client.MobileCommand.prepareArguments; import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT; @@ -43,7 +42,6 @@ import org.openqa.selenium.remote.http.HttpClient; import java.net.URL; -import java.time.Duration; import java.util.Collections; import java.util.Map; @@ -169,19 +167,6 @@ public IOSDriver(Capabilities desiredCapabilities) { super(updateDefaultPlatformName(desiredCapabilities, IOS_DEFAULT_PLATFORM)); } - /** - * Runs the current app as a background app for the number of seconds - * or minimizes the app. - * - * @param duration The time to run App in background. - */ - @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", duration.toMillis()))); - } - @Override public TargetLocator switchTo() { return new InnerTargetLocator(); }