feat(android): Allow custom timeout for terminate_application#448
Open
bipinsengar wants to merge 1 commit intoserhatbolsu:masterfrom
Open
feat(android): Allow custom timeout for terminate_application#448bipinsengar wants to merge 1 commit intoserhatbolsu:masterfrom
bipinsengar wants to merge 1 commit intoserhatbolsu:masterfrom
Conversation
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: appium/appium#14818
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses an issue where the terminate_application method for the UIAutomator 2 driver could fail due to a hardcoded 500ms timeout. This change introduces a configurable timeout parameter, giving users the flexibility to specify a longer duration for application termination.
Motivation and Context
The fixed internal timeout of 500ms was often insufficient for applications that perform cleanup tasks upon closing, or for tests running on slower hardware or simulators. This could lead to premature timeouts and result in flaky, unreliable tests.
By allowing users to set a custom timeout, we can significantly improve the stability of tests that rely on this functionality. This change directly resolves the problem described in issue #14818.
Implementation Details
The terminate_application method now accepts an optional timeout argument, specified in milliseconds.
To maintain backward compatibility and avoid breaking existing tests, the method defaults to the original 500ms timeout if no value is provided.
The underlying logic has been updated to pass this timeout value to the application termination process.
How to Use
Here is an example of how to use the new timeout parameter in a Python test script:
Default behavior (500ms timeout)
driver.terminate_app('com.example.my-app')
Custom timeout (e.g., 3 seconds)
driver.terminate_app('com.example.my-app', timeout=3000)
Related Issue
Closes: #14818