How Test Complete Handles Unexpected Windows

4
203
Handling Unexpected Windows

When you are designing your script and you know that a specific popup will appear on a particular event then you design your script in that way. You handle that using assertions something like below

But what if, when you are not aware of a popup window which appears suddenly due to an issue/bug/change in functionality. This could be due to many reasons. e.g. you are working on a printer dialog box and the window popup occurs as ‘printer out of paper”, which is an unexpected window.

The way TestComplete handles this situation, is in following sequence

1. Script execution is delayed until expiration of the “Auto-wait timeout” interval set in the project property, playback section.2. If the unexpected window is still open, TestComplete generates the “OnUnexpectedWindow” event. You can use this event to perform required action when an unexpected window appears. The event has the following parameters:

Sender: The Event control that processes the event.

Window: Specifies an unexpected window as a Window object.

LogParams: Properties of the LogParams object hold text, priority, color and other attributes of the error message posted to the log.

below is a simple example, which takes the screenshot and changes the message, when an unexpected window appears.

This event can be added to by adding ‘Events’ to your project.

3. If the window is not closed by the OnUnexpectedWindow event handler, TestComplete posts an error message to the log along with an image of the unexpected window and then acts according to the Playback settings:

  • If Stop on error is checked, then the run ends at that point.
  • If Stop execution is checked in the Unexpected Window section, Stops the execution

Otherwise, any of the four following actions is taken, depending on the settings in the Unexpected window section:

  • Click on focused button simulates a click to the window’s default button.
  • Press Esc simulates an ESC keypress.
  • Press Enter simulates an ENTER keypress.
  • Send WM_CLOSE sends the window the normal window-closing message.
  • If the window is still not closed (which may occur if you do not have a closing-action checked, or if the closing action(s) failed), the run ends

 

4 COMMENTS

  1. Is there any mechanism to handle run time errors so that the test run stops automatically and next test run continous to run if i parametarize routines through excel.

    As human intervention is required when VB Script run time error occurs and than run stops. It is stopping my next test runs.

    Apart from try catch mechanism, Can we handle this?

  2. Hi Shireesha,
    VB Script run time error can be easily handled using ‘On Error Resume Next’. Using this you can avoid the VBS Error dialog and so the human intervention.
    Apart from this, disabling ‘Error Dialog’ Option will let TestComplete continue the test execution without showing the error dialog.
    Furthermore you will need to disable Stop on error options, which will let testcomplete continue the script in case of any other error gets logged. You can find them on the Properties page of Project editor at Playback-Runtime. You will be able to view all the errors that occurred during the test run in the test log once your execution is complete.

  3. Thanks Saket ..I was facing the similar issue and was looking for the solution.I tried the approach suggested by you and it worked fine for me.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.