Let us know your feature requests - also vote for others.

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.

49 votes
Sign in
Password icon
Signed in as (Sign out)

We’ll send you updates on this idea

Pavel Kudrys shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Password icon
Signed in as (Sign out)
  • Daniel commented  ·   ·  Flag as inappropriate

    Hi everybody!

    I've been in contact with the Ranorex support department to know if if there is already a solution to stop a test run while handling a pop-up and resume it after the pop-up handling. It seems there is a solution (not tested by myself yet, pending to do it): within the list of automation helpers, use RequestPauseWhileExists.Maybe, you'll need to update the automation helpers.
    In my case, I'm going to insert my pop-up handlers in the 'While' iteration. The code of RequestPauseWhileExists is:

    private static void RequestPauseWhileExists(RepoItemInfo info, Element element)
    Report.Log(ReportLevel.Info, "Popup Watcher", string.Format("'{0}' popped up. Requesting pause of activity reporting while it exists.", info.FullName));

    while (Host.Local.Find(info.AbsolutePath).Count > 0)

    Report.Log(ReportLevel.Info, "Popup Watcher", string.Format("Resume activity reporting as '{0}' does not exist anymore.", info.FullName));

    I hope it can be useful for us all ;)

  • Pavel Kudrys commented  ·   ·  Flag as inappropriate


    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 (Ranorex Product Management, Ranorex) commented  ·   ·  Flag as inappropriate

    Hello everybody,

    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"];

    if (watchers.ContainsKey(key))
    throw new ArgumentException("Popup watcher with given parameters already exists.");

    var watcher = new PopupWatcher();
    watcher.Watch(findElement, AbortTestRun);
    watchers.Add(key, watcher);
    Report.Info("Popup watcher started.");
    return watcher;

    public static void AbortTestRun(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
    bool unused;
    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.

  • Wenlong P Xu commented  ·   ·  Flag as inappropriate

    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.

  • Noble Mathew commented  ·   ·  Flag as inappropriate

    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

Feedback and Knowledge Base