Python is a very popular language, and for good reason. A wealth of production-quality packages for performing all kinds of tasks is freely available on the Internet. But did you know that all this power is readily available in Squish tests, too? This article explains how to extend the Python interpreter shipped with Squish with different popular Python packages.

The Powerful Python Ecosystem

It comes as no surprise that many Squish users choose Python for developing automated GUI tests. Powerful language features, a clean and straightforward syntax, plus a wealth of documentation make it a perfect fit for professional GUI test automation scripts using froglogic’s Squish. However, one big advantage of Python over e.g. JavaScript is often neglected during GUI test development.

A wide range of Python programming tasks doesn’t need to be solved from scratch. Instead, a vast ecosystem of Python packages for solving all kinds of common (and uncommon) tasks is readily available – free of charge. Reusing this battle-tested code can prove to be a real accelerator for developing robust and reliable GUI test scripts.

To keep things manageable, these thousands of packages are maintained in a single place: the Python Package Index (PyPI). This provides a single point of contact to the Python package ecosystem, and an efficient search facility will typically find an existing Python package to solve most common tasks.

Installing Packages For Squish Tests To Use

PyPI is typically accessed using a command line tool called pip. This utility performs common maintenance tasks such as listing, installing, removing or updating installed Python packages. However, the Python installation shipped with Squish does not include the pip utility out of the box – this is to keep the package lean.

The first step to making packages stored in PyPI accessible to Squish test scripts is to install pip. This is a very simple three-step process:

  1. Download the installer script (if you are using Python 2, you will need to get the script for Python 2 instead)
  2. Open a command window and navigate to the Squish installation directory (e.g. C:\Users\Frerich\Squish for Web 6.4.3)
  3. Run the command python\python.exe C:\path\to\

The script will be executed, downloading the pip program and installing it. This will cause plenty of output to be printed to the console, like this:

C:\Users\Frerich\Squish for Web 6.4.3>python\python.exe C:\Users\Frerich\Desktop\
 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
 Collecting pip
   Using cached
 Collecting setuptools
   Using cached
 Collecting wheel
   Using cached
 Installing collected packages: pip, setuptools, wheel
   The script wheel.exe is installed in 'C:\Users\Frerich\Squish for Web 6.4.3\python\Scripts' which is not on PATH.
   Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
 Successfully installed pip-19.0.3 setuptools-41.0.0 wheel-0.33.1

The installation should finish within a couple of moments. At the end, the pip utility can be found in the Scripts subdirectory.

Verify that the installation worked by asking pip to print its version number:

C:\Users\Frerich\Squish for Web 6.4.3>python\Scripts\pip -V
pip 19.0.3 from c:\users\frerich\squish for web 6.4.3\python\lib\site-packages\pip (python 2.7)
C:\Users\Frerich\Squish for Web 6.4.3>python\Scripts\pip -V
 pip 19.0.3 from c:\users\frerich\squish for web 6.4.3\python\lib\site-packages\pip (python 2.7)

Congratulations! Thousands of Python packages are now available to your GUI test scripts!

Popular Python Packages

At this point, installing Python packages is just a mere pip install invocation away. In a command shell window, navigate to your Squish installation directory and run

python\Scripts\pip install PACKAGE 

where PACKAGE is the name of whatever awesome package whetted your appetite when browsing PyPI.

To get you started, here are a few great Python packages we used when creating Squish tests ourselves:

  • RPyC (install via ‘pip install rpyc’) is a lightweight but extremely powerful module for automating remote computers. After launching a tiny Python script on the remote machine, your Squish tests are able to execute arbitrary actions on the remote system in a very convenient way. This is great for e.g. preparing the remote system before a test, fetching system information during a test or cleaning up afterwards.
  • untangle (install via ‘pip install untangle’) is a tiny module which can be used to parse arbitrary XML files into Python objects – in a single line of code. This is great for reading all kinds of configuration files and is much easier to use than the standard xmllib Python module. Of course, it’s not as powerful — but sometimes you’d rather want to have just as much complexity as necessary instead of getting as much power as possible.
  • requests (install via ‘pip install requests’) is the de-facto standard for everything related to HTTP. Need to access a REST API in your Squish test? Upload some data to a web server? Fetch a status page? Look no further – the requests module has you covered. As the home page puts it: requests is “HTTP for Humans™”.

Final Words

At this point. you’re ready to augment your GUI test scripts by reusing any of the thousands of Python packages. Head over to the Python Package Index and see whether there’s a ready made package you can use instead of reinventing the wheel again and solving the problem manually!

What are your preferred Python packages when developing GUI tests using Squish? Let us know in the comments – we’d love to hear from you!

1 Comment

Thanks for the valuable article.
Interesting, how often Squish is being used in the market while accompanied with Python? Have you feedback from customers?

Leave a Reply

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

Copy link
Powered by Social Snap