Getting Started with Expressions, Variables, and Functions

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.

Quick Reference

CategoryFunction / VariableWhat It DoesExample
Expressions{{ ... }}Executes inline JavaScript during runtime{{console.log("Hello")}}
Local Variablefze.local.nameStores values only for current test executionfze.local.token = "abc123"
Project Variablefze.project.namePersists values across all tests in a projectfze.project.env = "staging"
TDM Variablefze.tdm.namePulls values from Test Data Management datasets{{fze.tdm.customerId}}
Action Datafze.action(id).attributeCaptures values from prior test steps (URL, text, etc.)fze.action("12345").url
Cookie Variablefze.cookie(name).valueReads cookies (session ID, tokens)fze.cookie("session-id").value
Clipboard Variablefze.clipboard()Captures clipboard contentsfze.local.clip = fze.clipboard()
Resource Variablefze.resource[url].attributeReads API/network request or response datafze.resource["/login"].statusCode
Page Variabledocument.titleGets current page titlefze.local.title = document.title
HTML StoragelocalStorage.getItem("key")Reads browser Local Storagefze.local.token = localStorage.getItem("auth")
Random Datafze.randomPhone("###-###-####")Generates phone numberfze.local.phone = fze.randomPhone()
fze.randomNumber(5)Generates random number of length nfze.local.zip = fze.randomNumber(5)
fze.randomString(8)Random alphanumeric stringfze.local.pass = fze.randomString(8)
fze.randomEmail("domain.com")Creates random emailfze.local.email = fze.randomEmail("test.com")
fze.randomDoB(1970, 2000)Random date of birth in rangefze.local.dob = fze.randomDoB(1980, 1990)
Operators.SubString(start, len)Extracts part of a stringfze.local.zip.SubString(0, 3)
.ToLowerCase()Converts to lowercasefze.local.name.ToLowerCase()
.ToUpperCase()Converts to uppercasefze.local.name.ToUpperCase()
.ExtractNumbers()Extracts digits from text"Order123".ExtractNumbers() → 123
.ExtractFloat()Extracts decimals"Price: 19.99".ExtractFloat() → 19.99
.Regex(pattern)Captures values via regex"Order#456".Regex("\\d+") → 456

 

Top 5 Practical Scenarios

1. Capturing and Reusing a Login Token

Goal: Store an authentication token from Local Storage after login and reuse it in later test steps or API calls.

// Capture login token
fze.local.authToken = localStorage.getItem("auth_token");

// Reuse in header for API request
fze.resource["/secureEndpoint"].headers.Authorization = "Bearer " + fze.local.authToken;

2. Generating Unique Test Users

Goal: Create dynamic, random user accounts for signup tests without collisions.

fze.local.email = fze.randomEmail("test.com");

fze.local.password = fze.randomString(12);

This is useful when running multiple parallel test executions that require unique credentials.

3. Validating a Page Flow with Verifications

Goal: Ensure checkout leads to a confirmation page with a unique order number.

// Capture order ID text
fze.local.orderId = fze.action("orderConfirmationStep").innerText;

// Verify format with regex
fze.local.orderId.Regex("\\d{6}");

This confirms the test didn’t just click through—it validated actual business logic.

4. Testing API Response Codes

Goal: Verify backend API responses in the middle of a UI flow.

// Capture status code
fze.local.status = fze.resource["/api/checkout"].statusCode;

// Verify response
fze.local.status == 200;

Great for end-to-end tests spanning UI + API.

5. Extracting and Formatting Data for Assertions

Goal: Grab the price displayed on a page and confirm it matches expected rules.

// Extract numeric price
fze.local.price = fze.action("priceElement").innerText.ExtractFloat();

// Verify price under threshold
fze.local.price < 100.00;

Combines operators (ExtractFloat) with logic for precise checks.