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

Squish for Web

If you are using squishtest from a Squish for Web package and want to start the Browser via squishtest.startBrowser(), you will find that this function is not available out of the box.

The reason is, that since you are not in a test suite context, the webhook must be started yourself. The two lines below accomplish that and after calling those, it should be possible to start the Browser if the extension has been installed before.

    squishtest.testSettings.setWrappersForApplication("__squish__webhook", ["Web"])

Functions provided by the squishtest module


This functions allows configuring the verbosity of the ‘squishserver’ process’ diagnostic and status output. (Also see squishrunner –debugLog .)

Status: Optional

Default: Not set


# Execute this before startApplication()
# and attachToApplication():


This is the equivalent to enabling sub-process hooking in the settings of a test suite (in the Squish IDE in test suite settings > Hook into sub-processes launched by the application (in the tab AUT).

Status: Optional

Default: True




Defines the output directory for fail images, etc. to use for certain report generators.

Status: Optional

Default: Not set



setTestResult(report_generator_name, result_dir_string)

Status: Mandatory

Default: Not set


squishtest.setTestResult("xml3", "C:\\Users\\myuser\\squish_xml_results")