Understanding Scripts

Create and run scripts that contain a mixture of automated and manual test steps.

Scripts are an important tool in organizing and running automated tests. All scripts are contained in the Script Library, accessible from the menu burger at the top left of Composer.

Each script that is owned by the account will be listed in order of short code (alphabetically), with the name and description on the left side and the various actions on the right. Scripts can be edited, run, and removed.

Creating Scripts

To create a script, go the Script Library and click on the floating action button at the bottom right to create a new script. The button will take you to the Script Editor page.

In the Script Editor, you can set the name, description, and short code of the script, and change the "runnable" toggle. The short code is for giving easy access to a script via the URL and is composed of only alphanumeric characters including the underscore '_' and hyphen '-'. The short code and the name of the script must be unique and are both required fields. The runnable toggle is to determine whether the script can be run as a job independently of other scripts. If you are unsure of whether it should be on or off, it is best to leave it on.

There are a variety of different steps that can be included in a script. The main type of steps is the automated test step, which can be entered by typing a command in the new step bar below the script information and pressing the Enter key or clicking the gear icon to the right of the new step bar. There are two other types of steps. Manual test steps can be entered by pressing the Shift+Enter key combination or clicking the hand icon to the right of the new step bar. Alias test steps can be entered by pressing the Control+Enter key combination or clicking the eye icon to the right of the new step bar.

Automated test steps can be converted to alias steps by clicking on the eye icon on the right of the step item. The command of the automated test step will become the command equivalent of the alias test step.

Once a step is created, it can be re-edited by clicking on the step, which will open the step editor for the specific type of step. Only one step can be edited at a time. When you click outside of the step editor or press the Enter key in the main text area of the editor, it will close and another step can be edited. When a step is not being edited, it can be removed as per the button on the right of the step. Steps can also be reorganized by dragging and dropping them in a linear fashion.

The script can then be saved by clicking the save icon to the lower right. When the script is saved, it will redirect you to the script editor of the existing script. The script editor for an existing script has two buttons at the bottom right, one with the save icon to save and another with the send icon to run the script (given that no changes have been made to the script).

Save Workspace Session as a Script

If you are using the Workspace and would like to save it as a script, you can click on the dropdown in the toolbar at the top and select "Save Workspace as Script" to create a new script. It will take you to the New Script page with a modal that allows you to choose which commands to include in the script depending on the results they have received. By default, only commands that are pending or have passed will be included. When the "Import" button is clicked, the commands will be propagated into the script, where it can be saved and run again.

Running Scripts

There are two ways to run a script. Scripts can be run as a Run, in the Workspace, or included in other scripts.

A Script 'Run'

One of the main ways of executing a script is by a Run. This can be done from the Script Library (to the right of a named script) of from a script's Script Editor. When a script is run, it will redirect you to the Run Results page. The contents of the script will run independent of the Workspace session. When all of the steps of the run have completed, the run session will be marked as done and any open browsers in the session will be closed.

A script can't be executed in a Run if the runnable toggle is off - it can only be included as a script.

Any scripts that are done, are pending, or are in progress will appear in the Run Results page. This page is accessible from the Run Results page by the breadcrumbs at the top under the logo, and also from the menu burger at the top left of Composer. Scripts that are in progress or pending can be aborted by pressing the delete button to the right of them. All runs can be cleared (including any in-progress or pending) by clicking the dropdown in the toolbar at the top and selecting "Clear Run Queue." The Run Results of any previous run that hasn't been cleared can be visited through this page as well by clicking on the name of a particular run.

Including Scripts

Scripts can be included both in the Workspace and in other scripts. Scripts do not need to be marked runnable in order to be included. They can be included either by short code or by name.

Any variables defined outside of the include command will not be overwritten by variables defined as parameters that have the same name. Nested includes will not implicitly inherit parameters - they must be explicitly declared for each include.

The variables defined in save variable commands such as in Save and Use Variables that are executed inside of scripts will still be usable in parent or sibling scripts (or in the Workspace).

CommandExamplesExplanation

include script "<Script Name>"

include script "Open Home Page"

Retrieves the named script if it exists and places all of the steps inside of the script at the head of the commands to be executed.

If the script does not exist, the step will return with an error.

include script with short code "<Short code>"

include script with short code "openWP"

Retrieves the script with the given short code if it exists and places all of the steps inside of the script at the head of the commands to be executed.

If the script does not exist, the step will return with an error.

include script "<Script Name>" where <Variable> is "<Value>" and <Variable> is "<Value>"

include script "Log in to Composer" where browser is "chrome"

Retrieves the named script if it exists and places all of the steps inside of the script at the head of the commands to be executed.

When this occurs, any variables that are defined in the include command will replace any occurrances of the named variables in the steps of the script.

Otherwise, if the script does not exist, the step will return with an error.

include script "Log in to Composer" where browser is "chrome" and username is "khoerr@toffeetesting.io"

include script "<Script Name>" with <Variable> = "<Value>", <Variable> = "<Value>"

include script "Rotten Potatoes" with movieTitle = "TMNT"

include script "Access secret safe" with MFAcode = "868431", print = "!!@@sa57"
include script with short code "<Short code>" where <Variable> is "<Value>" and <Variable> is "<Value>"

include script with short code "Calc-sqrt" where y is "144", and result is "12"

Retrieves the script with the given short code if it exists and places all of the steps inside of the script at the head of the commands to be executed.

When this occurs, any variables that are defined in the include command will replace any occurrances of the named variables in the steps of the script.

Otherwise, if the script does not exist, the step will return with an error.

include script with short code "Calc-mult" where x0 = "11", y0 = "17", z0 = "187"

include script with short code "<Short code>" with <Variable> = "<Value>", <Variable> = "<Value>"

include script with short code "ML_LOOKUP" with artist = "The Beatles" and record = "sgt-pepper"