Ability to pause/stop main test thread from popup watcher thread
Currently, the popup watcher runs in a separate thread, which does not allow interaction with test running in the main thread. Possibility to pause/stop main thread from popup watcher would be really handy! For example, in case the popup watcher finds an element, which should never appear during the test, it would be really great to have the possibility to stop the test and set it as failure. There is plenty of posts at forum regarding this issue. Thanks.
This feature has been released with a new version of the Automation Helpers.
How to use Automation Helpers:
Available with version: 1.3:
Ranorex Product Management Team
Pavel Kudrys commented
Thanks for providing a way to stop the test. I don't want to sound ungrateful, it's definitely nice to have a way to stop the test from popupwatcher ;) But it would be even more useful to have a way to PAUSE the test instead of killing it on first unexpected popup/element. I would really like to have an option to pause my tests on certain popups (appearance of certain elements), do some magic (like click this or that button, process certain innertext, save snapshot, etc.) and then instruct the test to continue with next action (next action after "pause") or fail test. Failing test on certain popups/elements is not always the best option how to handle popups. Thank you for the help.
AdminRanorex (Admin, Ranorex) commented
Thank you all for your valuable input.
There already is a way to stop the main thread and set the test to failed. The easiest way to achieve this is by doing a light modification of the automation helper for the popup watcher. Please refer to this instructions (for the automation helpers): https://www.ranorex.com/help/latest/ranorex-automation-helpers
You can then extend the PopupWatcherLibrary with this method:
public static PopupWatcher StartPopupWatcher_Abort(RepoItemInfo findElement)
var key = findElement.GetMetaInfos()["id"] + clickElement.GetMetaInfos()["id"];
throw new ArgumentException("Popup watcher with given parameters already exists.");
var watcher = new PopupWatcher();
Report.Info("Popup watcher started.");
public static void AbortTestRun(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
Ranorex.Core.ProcessAbortListener.AbortingProcess(Process.GetCurrentProcess().Id, TimeSpan.FromMilliseconds(-1) /*indefinitely*/, out unused);
Please let us know if this snippet helps you to stop your current test run! Thank you.
Jarosław Warias commented
a good solution would also be add a skip to the current step or move to teardown
Wenlong P Xu commented
Yes, it will be great if we can pause the main test thread from PopupWatcher thread, let the PopupWatch thread do its thing, then resume the main test thread to let the normal test actions go forward.
Stephan Bast commented
Noble Mathew commented
This would be really helpful if popup watcher can interact with the main test thread to pause or stop until pop watcher finish performing actions on the popups