Tony Fantacy
Tony Fantacy

Reputation: 63

UIAutomation - How to get around modal dialog blocking using windowopendedevent handler?

I'm trying to build an automated testing frame work for one of our product. Some of the test cases involves performing automation in modal dialog. However, modal dialog blocks the UIAutomation code from executing. In another word, if I have a modal dialog opened by UIAutomation, nothing happends until I close the modal dialog.

In order to excute the UIAutomation code when the modal dialog displays, I've been trying to register an windowopenedevent handler that catches the modal dialog when it's opened, so I can execute the rest of testings within the windowopenedevent handler. However, the handler is NOT catching the event at all. I have no idea what is wrong, any suggestions?

Other workarounds for this scenario is welcome, too.

Upvotes: 3

Views: 1291

Answers (1)

chrismead
chrismead

Reputation: 2243

I've run into this a few times, usually with browser testing.

What I've done is this:

>> before taking the action that causes the modal dialog to show up:
   >> start another thread (OR) launch a script asynchrounously
   >> then take the action

>> In the other thread or script:
    >> Sleep for 5 seconds or so
    >> Activate the dialog
    >> send keystrokes or call UI auto methods to dismiss the dialog

Your test should unblock once the dialog is dismissed.

This has always worked for me.

Upvotes: 2

Related Questions