Forum Discussion

SuperTester's avatar
2 years ago

Close Modal Windows

Hey guys!


I'm trying to figure out a way to close unexpected  modal prompts during playback that originate from the tested application.  I'm curious if anyone has had previous experience with this kind of problem.


From what I understand, because the modal prompts originate from the tested application, TC's "unexpected window" won't work (or atleast it hasn't so far).


I'd like implement it in a try catch statement:


test actions







I have two ideas for the closeModalWindows()


1. Use Find and get all windows in the application. Loop through each window and check its "isModal" property (which is a native java property of the window). If its modal, close it.

2. I'm reading Smartbears article on testing modal windows and I'm thinking about trying their approach, but confused on how it works.


Thought I'd ask before diving too far in! Seems like it would be a common problem.


Thanks in advance!



3 Replies

    • SuperTester's avatar

      Thanks for the response!


      This error prompt occurs unexpectedly when things are not going as planned!

      For example, the application is expecting to open a certain file type, such as a text file. However, due to an unexpected error in the script, it tries to open a .png file. The application launches its own error prompt that the script is not anticipating.

  • rraghvani's avatar
    Champion Level 3

    When you say, "unexpected error in the script", is that TestComplete script?


    From what you have described. I'll write a script to test for,

    • opening .png file, and verify error message is shown (checking invalid data is handled correctly)
    • opening .txt file, and verify document is opened (checking for valid data)

    These are the actions/results I expect from the application. If the application doesn't behave like this, then it's an issue with the application.