Global variables allow you to share data among tests while a build variable is meant for referring different values per build.
See Introduction of IDE to learn how to add these variables.
You can use global variables like any other variable in a programming language. They are stored as key-value pairs. Each key must be unique and can be assigned data of
number types. All the global variables defined in a project are accessible to any test within the same project. For example,
url = globals.SITE_URLprint(url) # prints, https://example.com
globals is the key used to access global variables,
SITE_URL is a stored global variable. All the global variables are auto suggested when you do
global. in IDE.
You can use global variables to store data that is frequently accessed from tests to minimize repetition, such as common element selectors, site URLs, passwords meant for tests or whatever you feel like.
You shouldn't store any sensitive information in these variables as they can appear in logs that you may accidentally share with someone else.
These are special purpose variables meant for pointing to different value per build. They are stored as key-value pairs. Keys can be duplicated and can be assigned data of
number types. The duplicate key feature allows you to assign a build variable to a specific value when running builds.
For instance, imagine you've written some tests for your production app, i.e those tests are using
openUrl(PRODUCTION_URL) but you want those tests to open different URLs of your application that you would like to provide while starting a build. This way you could tests your application in different environments such as
production with same tests. To do this, create following build variables (learn how to add):
Now whenever you start a build, from the Build Configuration screen you can assign a desired value to
SITE_URL. Any tests that use this build variable will resolve to the desired value.
isPrimary flag assigns a default value to a build variable to which it will resolve unless changed in a build.
Following ZWL snippet shows how to use a build variable:
openURL(buildVars.SITE_URL) # opens the url that is currently assigned to SITE_URL# Rest of the test
buildVars is the key used to access build variables,
SITE_URL is a stored build variable. All the build variables are auto suggested when you do
buildVars. in IDE.