Skip to content

Commit 822f004

Browse files
chore: Switch the implementation of backgroundApp for iOS, so it's in sync with other platforms (#1229)
1 parent 9020174 commit 822f004

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

src/main/java/io/appium/java_client/InteractsWithApps.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ default void resetApp() {
9595

9696
/**
9797
* Runs the current app as a background app for the time
98-
* requested. This is a synchronous method, it returns after the back has
99-
* been returned to the foreground.
98+
* requested. This is a synchronous method, it blocks while the
99+
* application is in background.
100100
*
101-
* @param duration The time to run App in background. Minimum time resolution is one second
101+
* @param duration The time to run App in background. Minimum time resolution is one millisecond.
102+
* Passing zero or a negative value will switch to Home screen and return immediately.
102103
*/
103104
default void runAppInBackground(Duration duration) {
104-
execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.getSeconds()));
105+
execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0));
105106
}
106107

107108
/**

src/main/java/io/appium/java_client/ios/IOSDriver.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.appium.java_client.ios;
1818

19-
import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND;
2019
import static io.appium.java_client.MobileCommand.prepareArguments;
2120
import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;
2221

@@ -43,7 +42,6 @@
4342
import org.openqa.selenium.remote.http.HttpClient;
4443

4544
import java.net.URL;
46-
import java.time.Duration;
4745
import java.util.Collections;
4846
import java.util.Map;
4947

@@ -169,19 +167,6 @@ public IOSDriver(Capabilities desiredCapabilities) {
169167
super(updateDefaultPlatformName(desiredCapabilities, IOS_DEFAULT_PLATFORM));
170168
}
171169

172-
/**
173-
* Runs the current app as a background app for the number of seconds
174-
* or minimizes the app.
175-
*
176-
* @param duration The time to run App in background.
177-
*/
178-
@Override public void runAppInBackground(Duration duration) {
179-
// timeout parameter is expected to be in milliseconds
180-
// float values are allowed
181-
execute(RUN_APP_IN_BACKGROUND,
182-
prepareArguments("seconds", prepareArguments("timeout", duration.toMillis())));
183-
}
184-
185170
@Override public TargetLocator switchTo() {
186171
return new InnerTargetLocator();
187172
}

0 commit comments

Comments
 (0)