Understanding Aliases

Create, activate, and substitute simple alias expressions for real commands.

Aliases can be created and activated only from scripts. There are three main components to aliases: the command, the alias expression, and the expected result.

  • The command: the equivalent step into which the alias expression is translated.
  • The alias expression: what the user enters that gets translated into the equivalent command.
  • The expected result: an optional statement that replaces the expected result of the command.


Creating Aliases

Aliases are created in scripts by typing a command into the new step bar and either pressing the control+enter key combination or clicking on the eye icon button on the right side of the new step bar. The entered string will serve as the command.

When the new alias is created, the step editor will automatically open and will not close until the required fields, the command and the alias expression, are filled. By default, the expected result is "Passed" - if the expected result is blank, then the expected result of the command is used when the alias is substituted.

It is not possible to create an alias of a manual command - alias expressions can be substituted only with automated commands.

Activating and Substituting Aliases

When the alias command is run as created above in a script, Toffee will activate the alias. No variables are substituted when an alias is activated.

Aliases on principle cannot be overwritten. This includes aliases with expressions where the variable names are different but the literals are the same. In the Workspace, the session can be cleared (thereby clearing all variables, aliases, and open browsers) via the dropdown on the right of the toolbar at the top, and then the alias can be activated.

The alias command itself will not run the command. Rather, any time the alias expression appears as an automated command, then the command will be substituted in its place. Therefore, the alias expression can be used multiple times without the need to declare the alias command each time. In addition, the alias command can be activated by including a script through the Workspace, and subsequently the alias expression can be used through the Workspace as any other automated command.

Using Variables in Aliases

One of the more useful features of aliases is being able to reuse an alias expression for a number of contexts. One way of achieving this is with inline variables.

Declaring an alias expression with variables

In the alias command (that is, for the alias activation), alias variables can be declared by surrounding an alphanumeric word with curly brackets:

This allows the browser variable to be used in the command and the expected result. When the alias is activated, you can run 'go chrome' and it will start the Chrome browser.

The first word of an alias expression cannot be a variable.

Variable substitution in aliases

Variables inside of aliases are exclusive to the aliases that declared them. They are not accessible outside of the alias expression that they were defined in. They also have precedence over non-alias variables. If a variable is not substituted by the alias, it may be substituted by a declared variable if one exists under the same name.

The substitution syntax is the same as for the other types of commands: see the Save and Use Variables page for more information on the different syntax for variable substitution.