The Expression Builder in Functionize enables you to add logic and dynamic data to your test cases. By using Variables and the fze object, you can capture values during runtime, reuse them across steps or projects, and even generate data dynamically. This allows tests to adapt to changing conditions and scale far beyond static, scripted test cases.
Expressions
An Expression is an executable JavaScript snippet wrapped in double curly brackets {{ }}.
Example: {{console.log('Hello World!')}}
- At runtime, this logs “Hello World!” into the console.
Expressions can be placed in:
- Input values
- Pre- and Post-Scripts
- Selector Overrides
- Verification Overrides
- VerifyVariable Actions
Like Custom JS, Expressions pass or fail depending on their execution result.
Variables
Variables let you store and reuse values during test creation and execution. These can be simple values (strings, numbers) or dynamic values (captured text, API responses, cookies).
Variable Scope
- Local Variables
- Exist only within a single test execution.
- Useful for temporary values such as order numbers, session tokens, or page content.
- Accessed with:
fze.local.variableName
- Project Variables
- Persist across test executions within a project.
- Shared globally across tests in the same project.
- Accessed with:
fze.project.variableName
- TDM Variables
- Linked to Functionize Test Data Management (TDM).
- Useful for pulling structured test data from external datasets.
Types of Variables
Functionize supports a wide range of variable types, each serving a unique purpose:
- Value – Hard-coded string or number stored for reuse.
- Previous Action – Captures attributes (text, URL, element state) from a prior test step.
- Cookie Variable – Stores browser cookies (e.g., session ID, auth tokens).
- HTML Storage Variable – Reads values from browser Local Storage.
- Page Variable – Stores page-level values such as
document.titleor the current URL. - Resource Variable – Captures request/response data from network calls.
- Clipboard Variable – Captures clipboard contents during a test.
- Custom Expression – Executes custom JavaScript to generate or transform values.
- Environment Configuration – Pulls environment-specific values (like credentials, endpoints).
Operator Functions
Operators transform or refine variable values. These can be chained in Expressions for powerful logic.
SubString(start, length)– Extracts part of a string.ToLowerCase()– Converts text to lowercase.ToUpperCase()– Converts text to uppercase.ExtractNumbers()– Pulls out digits from a string.ExtractFloat()– Extracts decimal numbers from text.Regex(pattern)– Applies a regex to capture specific parts of a value.
Built-in Functions via fze
The fze object is the interface to runtime test data.
Action Functions
fze.action([action_id]).[attribute]
Pulls data from a specific test step. Attributes may include .url, .text, .value, or element properties
Example: {{fze.action('1645900301653_STEPID').url}}
Cookie Functions
fze.cookie([cookie_name]).[attribute]
Reads cookies captured during the test. Attributes include .value, .domain, .path, .expiry.
Example: {{fze.cookie('session-id').value}}
Clipboard Functions
fze.clipboard()
Returns the most recent clipboard value.
Example: fze.local.clip = fze.clipboard();
Resource Functions
fze.resource[url].[attribute]
Accesses API/network traffic captured during execution. Attributes include:
.statusCode– Response code.requestHeaders– Sent headers.responseHeaders– Received headers.responseBody– Response content
Example: fze.local.StatusCode = fze.resource['https://functionizeapp.com/test'].statusCode;
Page & DOM Functions
document.title– Captures the page title.localStorage.getItem('key')– Retrieves values from browser local storage.
Random Data Generators
Functionize provides built-in random data generators to simplify test data creation:
fze.randomPhone(format)– Creates a phone number (e.g., ###-###-####).fze.randomNumber(length)– Random number of specified length.fze.randomString(length)– Random alphanumeric string.fze.randomEmail(domain)– Generates a unique email (e.g., for sign-up tests).fze.randomDoB(min, max)– Random date of birth between two years.
Resource Variables
Resource Variables let you validate API calls and network activity captured during a test.
Setup Steps
- Add whitelisted URLs in Team → Resource Tracker.
- Enable Capture network logs in Test Settings → Advanced.
- In Architect, create a Resource Variable from the Variables panel.
Use Cases
- Validate a response status code:
fze.resource['/login'].statusCode - Confirm request headers:
fze.resource['/cart'].requestHeaders['Authorization'] - Capture JSON tokens for reuse:
fze.local.token = fze.resource['/login'].responseBody.token
Advanced Variable Use
Variables can drive element selection or dynamically override test logic.
Example workflow:
- Capture dropdown text into a Local Variable with a SetVariable Action.
- Reference it in a selector override:
{{fze.local.dropdownValue}} - Architect dynamically uses that value during execution.
Best Practices
- Use Local Variables for temporary, per-test values.
- Use Project Variables carefully in parallel runs (values may be overwritten and race conditions may occur).
- Always include Verify Actions to validate dynamic values.
- Log captured values in Slider View for debugging.
- Use Custom Code Loops for repetitive API checks or data extraction.
Example Use Cases
// Increment a global counter
fze.project.orderCount += 1;
// Store current page title
fze.local.pageTitle = document.title;
// Capture login token
fze.local.token = fze.resource['/login'].responseBody.token;
// Generate a fake email
fze.local.email = fze.randomEmail('test.com');