Showing a message window during a script run

Sometimes it is necessary to interrupt the script being executed and display a certain message to the user, and then continue script execution only on condition the user closes the message.

Note however, that interaction of the automated tests with the user is considered bad style in testing automation, however, there could be instances when this cannot be avoided. For example, if we are running a lengthy test with a lot of actions, we may require that something be done manually in the middle of the test execution (for example, connect a device or reboot a remote server).

How to do it...

  1. To display the message and waiting for the coming interaction on behalf of the user, the BuiltIn.ShowMessage method is to be applied.
  2. In the following example its use is demonstrated:
    function testShowMessage()
    {
      Log.Message("This code will run before showing a message.");
      BuiltIn.ShowMessage("Press OK to continue execution...");
      Log.Message("This code will run after message has been closed");
    }

How it works...

The BuiltIn.ShowMessage method disrupts text execution and waits till the user clicks on the OK button. Meanwhile, access to other TestComplete possibilities is shut off. Test execution is expected to continue after the window has been closed.

There's more...

In TestComplete there is more advanced feature for user interactions—User Forms . With the help of User Forms one can create complex dialog windows with various controls elements. In fact, it is possible to create a small application within the TestComplete application. These forms can be useful if, before launching the tests, we would like to assign testing parameters (for example, address of the server, user name, tested application version, and any other customizable parameters).

If you would like, however, to have the possibility of launching tests in the automated mode without human interactions (for example, at night, on the weekend, or each time after the application has been compiled), these parameters are best stored in a configuration file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.42.134