From 5b77bd3e39d11c19cd1b78a841fdf0a6b790876e Mon Sep 17 00:00:00 2001 From: bipinsengar Date: Sat, 7 Jun 2025 17:12:52 +0530 Subject: [PATCH] Update _applicationmanagement.py feat(android): Add configurable timeout to terminate_application Previously, the terminate_application method had a hardcoded 500ms timeout. This could lead to failures on slower devices or under heavy load where the application could not terminate within the allotted time. This change introduces a timeout parameter to the terminate_application method, allowing users to specify a custom duration in milliseconds. If no timeout is provided, it defaults to the original 500ms to maintain backward compatibility. This provides more flexibility and prevents unnecessary test failures due to rigid timeout constraints. Fixes: https://github.com/appium/appium/issues/14818 --- AppiumLibrary/keywords/_applicationmanagement.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AppiumLibrary/keywords/_applicationmanagement.py b/AppiumLibrary/keywords/_applicationmanagement.py index 5b0d691d..58d6baa3 100644 --- a/AppiumLibrary/keywords/_applicationmanagement.py +++ b/AppiumLibrary/keywords/_applicationmanagement.py @@ -308,16 +308,17 @@ def activate_application(self, app_id): """ self._current_application().activate_app(app_id) - def terminate_application(self, app_id): + def terminate_application(self, app_id, timeout=500): """ Terminate the given app on the device Args: - app_id - BundleId for iOS. Package name for Android. + - timeout - Timeout for the terminate operation in milliseconds (default 500) New in AppiumLibrary v2 """ - return self._current_application().terminate_app(app_id) + return self._current_application().terminate_app(app_id, timeout=timeout) def stop_application(self, app_id, timeout=5000, include_stderr=True): """