Automate UI Testing of Windows applications under Wine on Linux

Automate UI Testing of Windows applications under Wine on Linux

If your Windows application runs fine under Wine, you can automate the GUI tests of your application using Squish for Windows running under Wine on Linux too. One reason to try Wine is to get a broader variation of Windows OS’es for finding hard to trigger bugs. Also, compared to a full blown Windows installation, the Wine setup is fast and easy.

I’ll start this quick walk-through with installing Wine on Linux. I use Debian, thus

$ sudo apt-get install wine winetricks
$ winetricks list-download

The last line is just to run winetricks once so the ~/.wine directory is created for me as user.

Next is to install Squish,

$ wine squish-6.4.0-windows.exe

and stepping through the installer dialog, I’ll get an installed Squish for Windows on my Linux system.

The goal is to run the application under test (AUT) under Wine, not to test Squish under Wine. The most minimal use of Wine with Squish is to start the AUT with the Squish tool startwinaut. The test script can then attach to the AUT.
Any Linux edition of Squish, e.g. Squish/Qt, can be used to connect to the AUT.

From the created Squish for Windows 6.4.0 directory, I run

$ wine bin/startwinaut.exe --port=1234 notepad

which starts notepad from the Wine installation, launched from Squish’ startwinaut.
As usual with attaching, in the Squish IDE’s Server Settings dialog, an Attachable AUT entry must be created, choosing localhost and port 1234, named it port1234.
Then a small script needs to be written:

function main() {

Place a breakpoint on the snooze line, run the script to the breakpoint, and then (e.g. via the Run menu), Record a Snippet.

That’s all you need to get a Windows AUT running with Squish on a Linux system.

What about using startApplication you may wonder? For this, squishserver must be running under Wine so squishserver can start Windows applications. I also need to register the AUT with squishserver.

$ wine bin/squishserver --config addAUT notepad c:\\windows\\system32
$ wine bin/squishserver.exe

In the Squish IDE Preferences dialog under remote testing, an external squishserver needs to be configured.

Side note, the contents of ~/.wine/drive_c/users/koos/Application\ Data/froglogic/Squish/ver1/server.ini is

AUT/notepad = "c:\\windows\\system32"
attachableAUT/port1234 = "localhost:1234"

Second side note, when squishserver needs to start an application, squishserver needs to know which toolkit wrapper is needed. Typically, this is provided by the WRAPPERS line in the suite.conf of your testsuite, so double-check that it has the correct value, Windows.

In the above recorded script, I only need to change attachToApplication("port1234") with startApplication("notepad") and I’m done.
When also setting notepad as AUT in the testsuite settings page, I should be able to record a full test case. But unfortunately that doesn’t seem to work. So recording needs the breakpoint and snippet recording way.

Koos Vriezen was born in Arnhem, Netherlands and studied in Nijmegen. During his studies of math and physics he became more and more interested in software development, and fell in love with Linux and C++ in the early 1990s. After working as a math and physics teacher for a few years, Koos switched to teaching official Microsoft courses for Visual Basic and introductory courses in C and C++. Later on he joined Polderland, a Dutch company that specializes in language and speech software, where he took part in various C++ projects, including development for the Dutch version of Microsoft's Office's grammar checking tool. Later still, Koos worked for an industrial automation company, Van Gelder Engineering. Around this time he joined the KDE team, initially doing KHTML bugfixes, and then moving on to specialize in KHTML KPart usage, as well as improving the Java applet support and adding the KMPlayer video plugin. Koos joined froglogic in spring 2006.


Leave a reply

Your email address will not be published. Required fields are marked *