Software QA FYI - SQAFYI

Automated Software Testing With Macro Scheduler

By: MJT Net Ltd

Part:   1   2 

Automated Software Testing With Macro Scheduler
Software testing can be a time consuming task. Traditionally QA technicians and/or programmers would sit in front of applications manually going through checklists to verify that the requirements of the software were met correctly.

Automated Testing using Macro Scheduler saves considerable time and resources. Macro Scheduler excels at testing software at the GUI level through its high level GUI functions and its ability to simulate user input.

Building a Test Script
This article will demonstrate how Macro Scheduler can be used for automated testing by way of a simple example. We will write an automated testing routine to test a small sample program, which converts inches to centimetres. Here s the example application:

To automate this test, the first step is to click the Convert button:
//Focus the app
SetFocus>Imperial - Metric Conversion
//check we get an error if we click Convert without entering a number
Press ALT
Release ALT

This produces the following error box with caption Error :

So we now want to wait for the error box to appear. We ll wait for the error box to appear, or 5 seconds, whichever is soonest and then see if the window appeared or not:

//wait for error box
//ok, the Error window appeared
TimeStamp>logfile,No data Error: Success
//cancel the error box
Press Esc
//No error window
TimeStamp>logfile,No data Error: Fail

Note that we write the outcome to a log file using the TimeStamp command. This is a convenient way to write data to a log file. The TimeStamp command outputs time information so you can also see how long the process took. Alternatively you could use WriteLn, or output directly to an ODBC database, or send data to Excel using DDE, or whatever else suits your needs best.

For the second step in the test plan we use the same approach we used in the first step. The full script is presented later. For now let s look at how we achieve the third and fourth steps where we want to get the value in the result box to see if it is what we expect. To do this we use the GetControlText function:

GetControlText>Imperial - Metric Conversion,TEdit,1,result

GetControlText takes the window title, a class name and an index and returns the text in the result variable.

Use the View System Windows Tool (from the Tools menu in Macro Scheduler) to find out the class name of objects on a window. Our sample application has two edit boxes of class TEdit.

Note that the second TEdit in the list is the Inch box and the first is the CM box. Objects are often created in reverse order to how they appear on a form. So we use index 2 to refer to the Inch edit and index 1 to refer to the CM edit.

Before pressing the Convert button we want to refocus the Inches box, clear it out and then send the data. So this whole section becomes:

//Send some valid data
SetFocus>Imperial - Metric Conversion
//clear inches box
SetControlText>Imperial - Metric Conversion,TEdit,2,
//focus inches box and send value (we could just use SetControlText!)
Press ALT
Release ALT

We then want to click the Convert button and extract the outcome to see if it is what we expect:

//Click Convert
Press ALT
Release ALT
//result should be 2.54
GetControlText>Imperial - Metric Conversion,TEdit,1,result
TimeStamp>logfile,1inch=2.54cm: Success
TimeStamp>logfile,1inch=2.54cm: Fail

We do the same thing for the fourth step in the test plan only we send 20 to the inch box instead of 1.

The Results
Let s look at the results of the test. The log file looks like this:
13:20:51:750 - No data Error: Success
13:20:52:765 - Bad data Error: Success
13:20:53:765 - 1inch=2.54cm: Success
13:20:53:781 - 20inch=50.8cm: Success

(Continued on next part...)

Part:   1   2 

Other Resource

... to read more articles, visit

Automated Software Testing With Macro Scheduler