Variables

Variables play a major role when scaling tests. They give flexibility to both run tests against many environments and to also manage test data. Some common uses are the base or launch url for your web application, api urls, login credentials, loop counters, etc.

When recording a new test, SnapTest will auto-create a "baseUrl" variable, after which all other actions and assertions are relative to that baseUrl. this enables you to change environments with ease.

Variables in Action

Variables are added to test actions in the "value" or "selector" fields. They are denoted using ${ <variablename> }. All variables at this point are strings.

Variable Source & Application Order

Variables can potentially come from six different places:

  • Built-in System variables: helper variables such as random integers.
  • Test default variables: used as backups in case you don't have an environment specified.
  • Component default variables: Similar to test default, but they also specify an interface for a component.
  • Environment Variables: A powerful way to apply sets of variables to any tests.
  • Component Instance Variables: Can accept all other variables as an input, thus being applied last for greatest flexibility.
  • Dynamic Variables: Applied on-the-fly using the "Add Dynamic Var" action.

Variable values from the various sources are applied from top to bottom, overriding each other as they go. Notice that environment variables are applied next to last, so they will almost always override other variables except for component instance variables. Environment variables apply to all variables within component instances of a test.

Variable Combining

You can combine/derive variables in environment and test/component sources.

Test default combining example:

Environment variable combining example:

Group 6Record it…Play it…Generate it…GeneratorsSelector AlgorithmsPrivate modeTest organizationTeamsWorkspacesDedicated supportTest data storageDebugger toolsAdaptable TestsCLI tools and APIWhite-labeled codeVariablesMulti-test playbackManual testsComponents