Automated GUI Testing for Qt for WebAssembly Applications

For years, Squish GUI Tester has been the go-to tool for testing Qt applications on desktops like Windows, Linux, and macOS, as well as on embedded systems. But with the latest version, Squish 7.2, users can now expand their testing capabilities to include Qt applications on the innovative Qt for WebAssembly platform.

In the video below we show how to make a Qt for WebAssembly application testable with Squish, how to create a few example automated GUI tests and ultimately demonstrate that Squish is a true cross-platform tool by running created tests on different platforms.

Testing Qt for WebAssembly applications with Squish

For quite some time, Qt for WebAssembly has been revolutionizing the way we run Qt applications on the web. By leveraging the power of web browsers as virtual machines, it allows seamless execution of binary wasm application modules, resulting in dynamic and interactive javascript runtime applications.

1. Make Qt for WebAssembly application testable with Squish

In order to enable testing of a "Qt for WebAssembly" application with Squish, it must be properly instrumented. Our specialized package, "Squish for Qt for WebAssembly," is designed specifically for this purpose. This package provides support for Qt-based applications running in the browser, for Qt versions 6.4 and 6.5.

The very first step is to modify the project file to add a Squish Qt Built-in Hook

!isEmpty(SQUISH_PREFIX) {

wasm {

SQUISH_BUILTINHOOK = 1

} else {

SQUISH_ATTACH_PORT = 4711

}

static: SQUISH_WRAPPER_EXTENSIONS += squishqtquick squishqtquicktypes

include($$SQUISH_PREFIX/qtbuiltinhook.pri)

}

 

Now we build our instrumented application 

qmake C:\Qt\Examples\Qt-6.5.1\demos\coffee\coffee.pro

SQUISH_PREFIX=C:\Squish\Qt\squish-7.2.0alpha-20230725-0545-qt65x-wasm-singlethread

 

mingw32-make

 

Please note that the same result can be achieved when using cmake, instead of qmake. Discover more information on this topic in the installation instructions of “Squish for Qt for WebAssembly” and Squish Qt Built-in Hook instrumentation chapter.

2. Run the Web Server with the instrumented Qt for WebAssembly application

Now you can go ahead and start you local web server

emrun –no_browser –port 8000 .

3. Implement automated GUI test using Squish for Web

 

From this point we use the standard Squish for Web package. After attaching to the web browser, the Qt application will appear as a dedicated application context in Squish.

Automating GUI tests for “Qt for WebAssembly” applications is similar to automating Qt applications on other platforms. The same methods such as recording, application spying, and test debugging can be used.

 

Comments