Handling Unexpected Popup Windows in Marathon

Sometime back there was a request on the marathon mailing list. Quoting the original post:

In my application there are some dynamically popup windows (something like dialog boxes) which are appeared while running a test scripts. I need to close those windows if they appeared without effecting the test. Can you please advice me how to do this in marathon?

In most cases, these annoying, test script failing popups occur due to an error in the runtime. For example, an exception in the Event Dispatch Thread might be captured and shown in a popup dialog. These error traces are very useful for the developers for identifying the location of a bug. Quite a few of these (especially those that are thrown by EDT) can safely be ignored.

A solution we provided for the OP is a WindowCloser class that just closes an identified window. You can see the details in the original thread.

With the release of Marathon/MarathonITE we are providing a generic solution.

Marathon provides 5 different ways of handling a popup.

  1. Fail(fail)
    Fail the test, but continue the script
  2. Fail and Close(fail-close)
    Fail the test, close the window but continue the script
  3. Abort(abort)
    Fail the test and abort the script
  4. Ignore(ignore)
    Do nothing
  5. Ignore and Close(ignore-close)
    Just close the window and continue the script

Which option you want to use, depends of course on your context.

For using one of these, call the following method in your script:

WindowHandler.add("title-of-the-window", "full-class-name", "action")

title-of-the-window is the window title (can be None/nil). If this starts with a ‘/’ the rest of the string is considered as a Java regular expression.

full-class-name is the fully qualified class name of the window object (can be None/nil).

action is one of “fail”, “fail-close”, “abort”, “ignore” or “ignore-close”.

Hope this feature solves the issues some of you are having. If you have comments/suggestions – post them either here or on the mailing list.


Add a comment

(it will not be shared)


Marathon Integrated Testing Environment, MarathonITE, is an affordable, easy-to-use and cross-platform Java/Swing™ GUI Test automation framework. You can use MarathonITE‘s inbuilt script recorder to create clean, readable test scripts either in Python or Ruby. Advanced features like extract-method refactoring, create-datadriven-tests and objectmap editing allows you to create maintainable, resilient test suites.