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.

50 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Pavel Kudrys shared this idea  ·   ·  Admin →

    6 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Pavel Kudrys commented  · 

        Hi,

        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  · 

        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:

        [UserCodeMethod]
        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);
        watcher.Start();
        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.

      • 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.

      • 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

      Feedback and Knowledge Base