The PopupWatcherLibrary provides methods to handle unexpected popup windows automatically. This prevents popups from disrupting or failing your test runs.
Prerequisites
Before using these methods, ensure you meet the following requirements:
- You must store the popup window itself as a repository item.
- You must store the UI element that closes the popup (for example, OK, Cancel, or the Close button) as a repository item.
PopupWatcher methods
You can add the following methods to your recording modules as described in Using the User Code Library.
StartPopupWatcher
This method waits for a specific popup window to appear and clicks a designated UI element to close it. You can run multiple watchers simultaneously, one after another, each watching for a different popup. However, running popup watchers uses resources. Make sure to stop the watchers when they are no longer needed using the methods below.
| Argument | Description |
| RepoItemInfo findElement | The repository item representing the popup window to watch for. |
| RepoItemInfo clickElement | The repository item representing the button the watcher clicks to close the popup. |
StopPopupWatcher
This method stops an active popup watcher that matches the specified findElement and clickElement arguments.
StopAllPopupWatchers
This method stops all currently active popup watchers in your test execution.
PauseWhileExists
This method waits for a popup window to appear and pauses test execution until the window disappears on its own. It does not click any UI elements.
Result
When a popup watcher is active, Ranorex Studio automatically pauses execution upon encountering the specified popup, performs the defined action (like clicking the OK button), and then resumes the test. The report includes an entry showing that the popup watcher successfully handled a window.