diff --git a/pom.xml b/pom.xml index 0af4a63..5f71c4f 100644 --- a/pom.xml +++ b/pom.xml @@ -189,13 +189,13 @@ com.github.aquality-automation aquality-selenium-core - 4.0.0 + 4.0.1 io.appium java-client - 9.1.0 + 9.2.2 diff --git a/src/main/java/aquality/appium/mobile/application/Application.java b/src/main/java/aquality/appium/mobile/application/Application.java index 400b4d4..7d93cb3 100644 --- a/src/main/java/aquality/appium/mobile/application/Application.java +++ b/src/main/java/aquality/appium/mobile/application/Application.java @@ -5,6 +5,7 @@ import aquality.selenium.core.configurations.ITimeoutConfiguration; import aquality.selenium.core.localization.ILocalizedLogger; import io.appium.java_client.AppiumDriver; +import io.appium.java_client.InteractsWithApps; import org.openqa.selenium.remote.service.DriverService; import java.time.Duration; @@ -85,4 +86,13 @@ public void quit() { getDriverService().stop(); } } + + /** + * Terminate the particular application if it is running. + * @param bundleId the bundle identifier (or app id) of the app to be terminated. + * @return true if the app was running before and has been successfully stopped. + */ + public boolean terminateApp(String bundleId) { + return ((InteractsWithApps)getDriver()).terminateApp(bundleId); + } } diff --git a/src/test/java/samples/android/nativeapp/apidemos/screens/AndroidScreen.java b/src/test/java/samples/android/nativeapp/apidemos/screens/AndroidScreen.java index ff01d0c..8af820e 100644 --- a/src/test/java/samples/android/nativeapp/apidemos/screens/AndroidScreen.java +++ b/src/test/java/samples/android/nativeapp/apidemos/screens/AndroidScreen.java @@ -21,7 +21,7 @@ protected void startActivity(Activity activity) { activity.getAppPackage()); AndroidDriver driver = (AndroidDriver) AqualityServices.getApplication().getDriver(); Map params = new HashMap<>(); - params.put("intent", activity.getAppPackage() + "/" + activity.getAppActivity()); + params.put("intent", String.format("%s/%s", activity.getAppPackage(), activity.getAppActivity())); params.put("package", activity.getAppPackage()); driver.executeScript("mobile: startActivity", params); }