Resource Variables Overview
Resource Variables are used to validate network calls that a page makes and to verify that it loads as expected. For example, a user may want to use resource variables to perform technical verifications. Resource variables offer a lot of flexibility.
Sample, simple Use Case: Verify that all network calls are loading as expected.
Sample, complex use case: Validating information within the DOM/source code to ensure that data matches the visual elements displayed on a page. Further, ensure that the segmentation is working as expected, and the correct subset of users is having the correct experience based on the information that is loading.
Note: If your use case involves capturing data from recurring API calls with Resource Variables, see this example.
Resource Variables are accessible within Architect.
To begin, it is important to set up which URLs are acceptable to show in the Resource Variable drop-down menu in the Architect.
To Set Up (Add) the Resource Variable URL's in Architect
-
Go to the Team tab in Functionize
Note: the Team tab is only available to an Functionize Admin. -
Click on Resource Tracker and then click + Add New Resource to define what URLs should show in the Resource Variable drop-down in Architect
- This is the Resource Tracker Whitelist
-
Please specify the URL of the resource(s) that need to be tracked in Architect
Note: Each Resource will be tracked for requestHeaders, responseHeaders, QueryString and associated parameters. - If Regex is selected, use the syntax as example: google.com/* or *google.com/* -- as wildcards
- When ready, click Save resources
- These will now be available when using a Resource Variable during test creation
-
In order for Resource Variables to be used during test execution, you have to ensure that the Capture network logs setting is ON under Test Settings > Advanced TAB
To Apply a Resource Variable
- Click the icon in the Architect
-
Click the Variables button
-
Select Resource Variables radio button
-
Select the appropriate URL for verification from the URL drop-down menu
-
Select the Attribute name, in this example, the user is selecting statusCode
-
Select the Operator - if you need to use one of the following functions on the data from the Resource Variable:
- Substring
- ToLowerCase
- ToUpperCase
- Extract Numbers
- Extract Float
-
Regex
- The Value will auto populate with the current Resource Variable value
-
Click Set Target to enter the Resource Variable Result into the an input field on the website
Capture a Resource Variable in a Local/Project Variable
- Click the Variables icon button in the Architect
-
Click the + Add Variable button
-
Select the variable Scope, enter a variable Name and select variable Type as Resource Variable
-
Select the URL from the drop-down list and select the Resource Variable Attribute, in this example 'statusCode' and if you need to select one of the following functions on the data from the Resource Variable:
- Substring
- ToLowerCase
- ToUpperCase
- Extract Numbers
- Extract Float
-
Regex
-
Click Save button to store Resource Variable in your Local/Project variable
- See additional details on how Local/Project Variables can then be used to validate Resource Variables
Resource Variable Examples
Functionize Resource Variables has the capability to retrieve data from your requestHeaders
and responseHeaders
, store in Functionize Variables (Local and Project) and use throughout your test execution. Here are some samples of how to use Resource Variables:
//Retrieve Resource Variable statusCode
fze.local.StatusCode = fze.resource['https://functionizeapp.com/testsites/anaqa/index.php'].statusCode;
//Retrieve Resource Variable requestHeader data
fze.local.RequestHeader = fze.resource['https://functionizeapp.com/testsites/anaqa/index.php'].requestHeaders['User-Agent'];
//Retrieve Resource Variable responseHeader data
fze.local.ResponseHeader = fze.resource['https://functionizeapp.com/testsites/anaqa/index.php'].responseHeaders.date;