Running a large number of tests against different browsers and across multiple platforms can take a long time. A common approach to reducing this time is to distribute the execution across several systems, and run the tests in parallel. The setup of a number of systems is often completed in an automated fashion, which Squish already supports.
But there’s a catch: in order to provide an extensive API for automation of the browser, Squish for Web requires installing a browser extension in Firefox. To avoid installation of malicious extensions without the user’s consent, Mozilla requires a manual process of installing the extension. Thus, for each system that will run tests with Squish in Firefox, a manual setup step must be performed.
In the following sections, we present a semi-automatic method of handling this extension installation. The solution we show leverages the fact that Squish will use a fixed profile-directory for the browser, in which all information about the extensions is stored. Our solution is two-fold:
- Install the extension once, manually. Then,
- With the browser profile now containing the extension, copy the profile directory in an automated manner on any number of systems.
Let’s get started.
Installing the Firefox Extension Once On Any System
The first step is to run through the setup process for the browser extension once. You can do this on any system, but it’s better to use a system where the user account name is the same as on the systems onto which the browser profile will be distributed. (We’ve found that Firefox may have some issues on the first start with a browser profile created under a different user account; the second and subsequent runs of the browser work as expected.)
The extension process can be triggered from the Squish IDE. In the Server Settings Dialog, select the Browser page, and from the dropdown, select Firefox as browser, and then click the Install button.
Alternatively, it’s possible to start the process from a command line utility, lib/exec/browserextensionhelper command:
cd <squish-installation-folder> lib/exec/browserextensionhelper installBrowserExtension firefox
Once the browser starts, a popup appears which asks for permission to install the Squish extension. The popup needs to be acknowledged using the Install button. Finally, terminate the browser: usually by closing the browser window. On macOS, it’s necessary to exit the browser via the application menu’s Quit option.
Distribute the Prepared Browser Profile
Once the installation process if complete, the browser profile which Squish automatically generates contains the installed extension, in addition to the user acknowledgement which allows loading the extension. This profile folder can be copied to other systems, enabling the distribution of a ready-made setup for launching Firefox.
The profile folder is named
squish_firefox_profile_dir and is generated in the so-called Squish user settings directory. The user settings directory on macOS and Linux systems is
$HOME/.squish and on Windows systems is
%APPDATA%/froglogicSquish. (The directory can also be specified using the SQUISH_USER_SETTINGS_DIR environment variable.)
How the folder is transferred to the test execution systems depends on how those systems are to be prepared for test execution. Possible options include using:
- the scp utility from openssh, or pscp from the putty suite.
- the robocopy command built into Windows.
- downloading the profile as a zip from a shared location and unpacking it.
- using a version control system like git to distribute it, and then copying or linking it to user settings directory.
Regardless of which method is used for the transfer, the folder
squish_firefox_profile_dir needs to be placed into the Squish user settings directory on the target system.
The browser directory folder also includes all configuration information from the browser, so changes to the defaults will be distributed as well, for example, disabling the automatic update process. The configuration of Firefox can be done by creating a user.js file in the profile folder or via the UI of Firefox. When using the UI, it is important to use the same browser profile that Squish uses, so it’s best to start Firefox through Squish.
Distributing the browser profile this way also enables an update of the extension in an automated fashion. Firefox allows you to place the
squishWebExt@froglogic.com.xpi file found in the
lib folder of your Squish for Web installation into the profile directories’
extensions sub-directory, overwriting the existing file. Upon the next start of Firefox, the new version of the extension will be loaded without any further acknowledgement required.