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 126.96.36.199 we are providing a generic solution.
Marathon provides 5 different ways of handling a popup.
Fail the test, but continue the script
- Fail and Close(fail-close)
Fail the test, close the window but continue the script
Fail the test and abort the script
- 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.