During test execution, a pop-up or dialog may appear, preventing the target element from found located and causing the test to fail.
This article explains how to handle pop-ups and dialogs that appear during testing.
Prevent pop-ups/dialogs from appearing
You can avoid test failures caused by pop-ups by configuring the site or app under test to suppress pop-ups in the test environment.
To learn how to automatically grant system permission dialogs during mobile app testing so they no longer appear, see the following page:
How to test whether the system permission dialog shows up
Add a step to close the pop-up/dialog
If the pop-up appears at a predictable time
Add a step that clicks the button element to close the pop-up or dialog.
If the pop-up does not appear consistently, use a conditional branching command such as "If UI element is visible."
When the pop-up appears at random times
Currently, there is no feature available to handle pop-ups that appear at unpredictable times.
Please consider configuring your site or app to prevent pop-ups/dialogs from appearing.
This has been filed as a feature request at the link below. By voting on it, you can help inform our development priorities and receive a notification when the issue is resolved. We would appreciate your consideration.
Pre- and post-processing of each step
Special dialogs
For information on handling special dialogs, such as those displayed by the browser, see the following:
How to handle the “wants to open this application” dialog in tests
How to handle the “Sign in to Chrome?” dialog in tests