Our test team uses HP QuickTest Professional (QTP) to perform data loads by importing data from an MS-Excel workbook and using a Web Form to load the data. Some data loads took a while and some were performed outside office hours. As these data loads were performed manually via the QTP GUI, QTP errors would be detected only when the Test team personnel manually check the results of the QTP run, thereby delaying further action or resolution. Given below is a solution to enable receipt of email notifications for terminating QTP errors:

STEP 1: Record and save a test using the QTP GUI

Using the QTP GUI, record the user journey for your test and save the results. Let’s assume you save the QTP test in C:\QTP\Test1

STEP 2: Customize settings using VBScript

Download the VBScript template QTPAutoRunTemplate.vbs (download zip and extract) and place it in the QTP test directory (C:\QTP\Test1). If you are familiar with the QTP Automation Object Reference model, then you may customize the test settings in this VBScript template. Note that the line qtTest.Settings.Run.OnError = "Stop" in the template. This setting was used as our requirement was to stop the QTP test upon first error. Also, this solution was built using this setting as a pre-requisite.

STEP 3: Execute QTP Test using PowerShell

Download the PowerShell Script QTPAutoRun.ps1 (download zip and extract) and do the following:

(1) Edit the script using your favorite editor and do the following:

Set the $email_recipients variable on line 64 to appropriate value(s).

Set the $smtp_server variable on line 65 to an appropriate value.

(2) Execute the script. This script will do the following:

Modify QTPAutoRunTemplate.vbs to include the path to the recorded QTP test (passed as a parameter to the script).

Execute QTPAutoRunTemplate.vbs and capture the results.

Check the results and dispatch email notifications.

NOTE: In order to execute the PowerShell Script, you must have Windows PowerShell 2.0 installed on your Windows machine. For email notification to work, you must have connectivity and authorization to use the SMTP server to relay email.