Variables and Snippets

Just like steps anywhere in a robot, the steps in a snippet can use variables. The steps of snippets are always edited inside a robot. In that context the variables defined on the robot can be used in the snippet. Reusing the snippet in another robot requires you to define the variables used by the steps in the snippet on each robot that uses the snippet.

A snippet can define its own variables. Open the snippet in its own editor to define variables on the snippet. If the snippet already contains steps using variables that existed in the robot where the snippet was edited, the steps are marked with a red flag.


Load Page Snippet

The preceding image shows a snippet in its own editor, that uses a variable not defined on the snippet itself.

Notice the active variables editor in the lower right corner, exactly as on robots.

If a snippet defines variables, using the snippet in a robot automatically adds the snippet variables to the set of variables for the robot.


Load Page Snippet

The preceding image shows a robot that uses a snippet that defines a variable 'url'.

Notice the variables imported from snippets are marked in the variables list.

A robot should not contain variable definitions by the same name as variables defined in the snippets it uses. If it does, the variable types must match.

Removing a snippet from a robot also removes the variables imported by that snippet.