Using Squish as a module in other Python scripts, applications

Last edited on


It is possible to automate user interfaces using the Squish API from existing Python scripts using a special Python module called squishtest.

Obtaining a Squish package with the correct Python configuration

The squishtest module functionality is available free of charge and is included in all Squish packages.

However, if you are using a Python installation with a different point-release (or architecture) from what is included in the Squish package, the Python module will not be compatible with your Python installation. In this case, you need a Squish package custom built with a Python version that matches your Python installation.

To provide such a package we need the following from you:

To determine the exact version and information about UCS-2 or UCS-4 please send us the output generated by running the following command:

python -c "import sys; print sys.version; print sys.maxunicode"
Execute in a shell

Using the squishtest module in Python scripts

A simple Python script using squishtest might look like this:

import squishtest

import names

# Must set a test result:
squishtest.setTestResult("xml3", "testresultdir")

# Must specify which GUI toolkit support Squish
# should use for this application.
# This depends on the Squish edition; possible values:
#  Android, iOS, Java, Mac, Qt, Tk, Web, Windows
squishtest.testSettings.setWrappersForApplication("addressbook", "Qt")

# Launch the application:

# Start interacting with the application...


The above example test script can be executed with a plain Python interpreter, as long as the environment is configured correctly for finding the squishtest module, its shared library dependencies and a few other items, as shown below:

# Path to Squish package:
export SQUISH_DIR=/home/myuser/squish-6.5.2

# To find the "squishtest" module:

# To find shared libraries squishtest depends on:

# To find these Squish modules:
#  objectmaphelper (possibly used in
#  remotesystem
#  screen
#  toplevelwindow

# Launch squishserver in background:
"$SQUISH_DIR/bin/squishserver" --verbose &

# Execute Python script that uses squishtest:
On Unix: Execute in a shell/terminal
:: Path to Squish package:
set SQUISH_DIR=C:\Users\myuser\squish-6.5.2

:: To find the "squishtest" module and shared libraries
:: it depends on:

:: To find these Squish modules:
::  objectmaphelper (possibly used in
::  remotesystem
::  screen
::  toplevelwindow

:: Launch squishserver in background:
start "" "%SQUISH_DIR%\bin\squishserver" --verbose

:: Execute Python script that uses squishtest:
On Windows: Execute in cmd.exe