Endtest

Endtest

›Advanced

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

Variables

Introduction

It's considered a best practice to use variables in your tests.

This helps you avoid situations where you need to update the same value in multiple places.

Declaring variables

You can use the Set Variable action to declare a new variable.

The options from the Set Variable action allow you to enter, extract or even generate values.

All variable names must start with the $ character.

Once declared, a variable can be used across the entire test suite.

If you want to use it in other test suites, you have to import the test case in which the variable was declared.

Variable Types for Web Tests

Variable TypeDescription
Set ValueSet a hardcoded value.
Set PasswordSet a hardcoded masked value.
Set SecretSet a hardcoded masked value, protected by an extra layer of encryption.
Random NumberGenerate a random number.
Random StringGenerate a random string.
Random EmailGenerate a random email address.
Real Phone NumberSelect one of the real phone numbers for testing assigned to your Team.
TimestampGenerate a timestamp.
UUID (Universally Unique Identifier)Generate a 128-bit universally unique identifier (UUID)
Generate OTP from Secret KeyGenerate the OTP from a Secret Key, just like an Authenticator app.
Extract Value from ElementExtract the text from an element.
Extract Value from Element with OCRExtract the text from an element by using Optical Character Recognition.
Extract Attribute from ElementExtract the value of an attribute from an element.
Extract CSS Property from ElementExtract the value of a CSS Property from an element.
Extract Value from JavaScript VariableExtract the value from a JavaScript variable.
Extract Value from AlertExtract the text from an Alert box.
Extract CSS Selector from Focused ElementExtract the CSS Selector from a focused element.
Extract Result from SQL QueryExtract the results from a SQL query.
Extract Latest SMSExtract the latest SMS sent to a real phone number.
Extract Current URLExtract the URL from the current page.
Extract Current TitleExtract the title from the current page.
Extract Number of Child ElementsExtract the number of direct child elements from a parent element.
Extract Number of ElementsExtract the number of elements by providing a locator.
Extract Name of Most Recent Downloaded FileExtracts the name of the last downloaded file.
Extract Size of Most Recent Downloaded FileExtracts the size (bytes) of the last downloaded file.
Extract MIME Type of Most Recent Downloaded FileExtracts the MIME Type (case-sensitive) of the last downloaded file.
Link to Most Recent Downloaded FileReturns a download link to the last downloaded file.

Variable Types for Mobile Tests

Variable TypeDescription
Set ValueSet a hardcoded value.
Set PasswordSet a hardcoded masked value.
Set SecretSet a hardcoded masked value, protected by an extra layer of encryption.
Random NumberGenerate a random number.
Random StringGenerate a random string.
Random EmailGenerate a random email address.
Real Phone NumberSelect one of the real phone numbers for testing assigned to your Team.
TimestampGenerate a timestamp.
UUID (Universally Unique Identifier)Generate a 128-bit universally unique identifier (UUID)
Generate OTP from Secret KeyGenerate the OTP from a Secret Key, just like an Authenticator app.
Extract Value from ElementExtract the text from an element.
Extract Value from Element with OCRExtract the text from an element by using Optical Character Recognition.
Extract Attribute from ElementExtract the value of an attribute from an element.
Extract Coordinates from ElementExtract the coordinates of an element.
Extract Width from ElementExtract the width of an element.
Extract Height from ElementExtract the height of an element.
Extract Result from SQL QueryExtract the results from a SQL query.
Extract Latest SMSExtract the latest SMS sent to a real phone number.
Extract WebView Context NameExtract the name of the WebView context (for Hybrid Mobile Apps).
Extract Number of Child ElementsExtract the number of direct child elements from a parent element.
Extract Number of ElementsExtract the number of elements by providing a locator.
Extract Value from Cookie (Web Context)Extract a cookie from the WebView context (for Hybrid Mobile Apps).
Extract XPath of Lowest ElementExtract the XPath of the lowest element on the screen.
Extract XPath of Highest ElementExtract the XPath of the highest element on the screen.

The Variable Types which involve randomness have mandatory inputs for rules which control that randomness.

For example, the Randomn Number option requires users to declare a value for the Length of Number.

And the Random Email option requires users to declare a value for the Email Domain.

The Real Phone Number and Extract Latest SMS options require your account to be associated with real phone numbers.

We provide real phone numbers for our users. You don't have to use any external service.

If there are no real phone numbers associated with your account, please contact our Support Team.

More information is available in the Read SMS chapter.

You can also declare variables directly in the Endtest API request for starting a test execution, more details are available in the Endtest API chapter.

Using variables

After you set a variable, you can use it in other steps or cases by simply entering its name in any input.

Simply typing $ inside an input will display a dropdown with the available variables.

You can concatenate variables with strings or with other variables by placing the variable name between double curly brackets:
My name is {{$username}} and my email is {{$email}}

You can also print the variables in the Results by using the Variable or All Variables options from the Print in Results action.

System variables

System variables are automatically created in each test execution.

They can be used in If Statements or other steps.

System variables for Web Tests

System Variable NameDescription
$systemTypeDesktop or Mobile
$systemPlatformWindows, Mac, Android or iOS
$systemBrowserChrome, Firefox, Internet Explorer 11, Edge or Safari
$systemGeolocationThe selected Geolocation
$systemResolutionThe selected Screen Resolution
$systemResolutionWidthThe width of the selected Screen Resolution
$systemResolutionHeightThe height of the selected Screen Resolution
$systemYearThe current year
$systemMonthThe current month (e.g. 1, 2, 3)
$systemMonthNameThe current month name (e.g. January, February, March)
$systemMonthShortNameThe current month short name (e.g. Jan, Feb, Mar)
$systemDateThe current date (e.g. 1, 2, 3)
$systemDayThe current day (e.g. Monday, Tuesday, Wednesday)
$systemTestExecutionHashThe hash of the current test execution
$systemCurrentLoopIterationThe current loop for an Import Test Case Multiple Times step
$systemLatestScreenshotLinkThe URL for the latest screenshot
$systemLatestWebCrawlerLinkCountThe number of links found in the latest Start Web Crawler step
$systemErrorCounterThe current number of Errors
$systemPassedCounterThe current number of Passed Assertions
$systemFailedCounterThe current number of Failed Assertions
$systemTestCaseNameThe name of the current test case
$systemUserEmailThe email of the user who started the test execution
$systemNotesThe text provided in the Additional Notes input

System variables for Mobile Tests

System Variable NameDescription
$systemPlatformAndroid or iOS
$systemDeviceThe name of the device
$systemAppDownloadUrlThe online path for the APK or IPA file
$systemWidthThe width of the device screen
$systemHeightThe height of the device screen
$systemYearThe current year
$systemMonthThe current month (e.g. 1, 2, 3)
$systemMonthNameThe current month name (e.g. January, February, March)
$systemMonthShortNameThe current month short name (e.g. Jan, Feb, Mar)
$systemDateThe current date (e.g. 1, 2, 3)
$systemDayThe current day (e.g. Monday, Tuesday, Wednesday)
$systemTestExecutionHashThe hash of the current test execution
$systemBrowserStackBuildIdThe BrowserStack Build ID of the current test execution
$systemBrowserStackSessionIdThe BrowserStack Session ID of the current test execution
$systemCurrentLoopIterationThe current loop for an Import Test Case Multiple Times step
$systemLatestScreenshotLinkThe URL for the latest screenshot
$systemErrorCounterThe current number of Errors
$systemPassedCounterThe current number of Passed Assertions
$systemFailedCounterThe current number of Failed Assertions
$systemTestCaseNameThe name of the current test case
$systemUserEmailThe email of the user who started the test execution
$systemNotesThe text provided in the Additional Notes input

Transfer variables to JavaScript

You can even transfer a variable to JavaScript, by using the Transfer to JavaScript action.

After that, you can perform different operations with that variable in JavaScript with an Execute JavaScript step.

If you want to transfer a variable from JavaScript, you need to use the Extract value from JavaScript Variable option from the Set Variable action.

You can find more details about the Execute JavaScript action in the Execute JavaScript chapter.

← Performing Complex GesturesWaits →
  • Introduction
  • Declaring variables
    • Variable Types for Web Tests
    • Variable Types for Mobile Tests
  • Using variables
  • System variables
    • System variables for Web Tests
    • System variables for Mobile Tests
  • Transfer variables to JavaScript
© Endtest Inc.