Desktop Application Testing

Testing of desktop applications can be performed within a single workstation through the “Local Desktop” connection method or alternatively through the “VNC Server” connection to a second virtual or physical environment.

Both of the above mentioned connection types allow you to control the entire test environment (SUT) and therefore inherently any applications that are installed there. Testing of this kind however is not limited to any single application, can also include the install/removal of applications along with viewing/adjusting system properties etc.

In fact, once you are connected to the desired SUT you can control any aspect of that environment in exactly the same way that a user would do, manipulating it via the mouse and keyboard whilst analysing the resulting display visually.

It is important to understand that Robot differentiates only the connection type being used, not the application type. Therefore, a native desktop application is handled and automated in exactly the same way as, for example, a web, .NET, Java, Flash, etc application.

Let’s take an example of launching an application…

Firstly launching a standard desktop app such as Calculator would be achieved using the following code in Robot:

Press Windows
Typeline Calc
Comparing that against the code required to launch a web browser application:
Press Windows
Typeline "iexplore www.gmail.com"

Once the application has been started the steps needed to automate it depend on the design of the application itself in terms of the menu/field navigation, data entry, etc. This will in turn determine whether you want to use the mouse or keyboard to perform such actions.

For example, performing an equation in the Windows Calculator could be achieved as follows:

Typeline 5*5
And logging into the Gmail web application, as follows:
Type T-Plan@gmail.com
Press Tab
Typeline testing123

Video of Windows Calculator Sample

However, if you are unsure or indeed know that your application does not support keyboard navigation etc you can use Image and/or text searching as a basis for your mouse.

Calculator example based on image searches:

Procedure Click {
Waitfor match template="{1}.png" method=search2 timeout=10s
if ({_EXIT_CODE} > 0) {
Step "Click {1}." result=fail
Exit "1"
} else{
Step "Click {1}"
Mouse click to=x:{_COMPARETO_CLICK_X},y:{_COMPARETO_CLICK_Y}
}
}
Click WinStart 
Typeline Calc
Click 5
Click Times
Click 5
Click Equals 

Similarly, testing of the web application would look the same:

Procedure Click {
Waitfor match template="{1}.png" method=search2 timeout=10s
if ({_EXIT_CODE} > 0) {
Step "Click {1}." result=fail
Exit 1
} else{
Step "Click {1}"
Mouse click to=x:{_COMPARETO_CLICK_X},y:{_COMPARETO_CLICK_Y}
}
}
Click WinStart
Typeline "iexplore www.gmail.com"
Click Email
Type T-Plan@gmail.com
Click Password
Type testing123
Click SignIn

The final part of the jigsaw is then to perform the verification of the applied action. This can again be achieved a number of different ways including typically an image or text search.

Wrapping such a verification into a procedure also means that you can place a verification point at each desired step of your script.

A procedure can include any code you require but a typical verification action may look as follows: 

Procedure Verify {
Waitfor match template="{1}.png" method=search2 timeout=10s
if ({_EXIT_CODE} > 0) {
Step "Verify {1}." result=fail
Exit 1
} else{
Step "Verify {1}"
Screenshot "Verification_{1}.png"
}
}

This procedure is then called wherever needed throughout your script like so:

Verify 25

For further example of T-Plan Robot automating local web application please see our Google Maps video: Map testing with T-Plan Robot.