Although Functionize is a no-code solution at its core, we also support custom code in several areas of the platform. This gives advanced users the flexibility to extend test cases, add highly specific checks, or integrate external logic when needed.
One of the most common ways to introduce code into a test is through the Custom Code Action, which allows you to add JavaScript directly into your test flow.
Custom JavaScript Action
Where it can be added:
- Architect (during recording)
- Slider View
- Test Detail Page
What it does:
- Lets you write custom JavaScript that can interact with the browser in any way.
- Must return a Boolean value (
true/false) or variable value. - The step will pass or fail based on the returned value.
Example Use Cases
- Verifying that the correct number of blog entries appear on a page.
- Ensuring all ads load from the correct domain.
- Checking that information appears in the correct order (e.g., sorting or ranking).
Handling Asynchronous Functions
If your JavaScript includes asynchronous behavior (such as an API call, async map, or timeout), you must use the built-in Functionize async callback:
functionizeAsyncCallback(boolean result)
This ensures the action completes only after the async process finishes.
Editing Custom Code
Custom Code Actions may be updated after recording:
- Test Detail Page → Expand Action → Action Settings → Custom Code
- Slider View → Gear Icon → Action Settings → Custom Code
You can modify, extend, or replace your script directly in the provided editor.
Customizing the Result Message
By default, a Custom Code Action passes/fails with no additional context. However, you can customize the result message returned with the action for better debugging.
Syntax
Return a JSON-formatted string with result and message:
return '{ "result": false, "message": "This step is failing for XYZ reason" }'
- result → Boolean (
trueorfalse) - message → Custom string explaining why the step failed
Using Variables
You can also leverage Functionize variables for dynamic result messages:
return '{ "result": false, "message": {{fze.local.errorMsgs[2]}} }'
This makes it possible to pull custom error strings or dynamic values captured earlier in the test.
Customizing the Failure Message
This can be achieved by adding a custom failure message in the 'Failure Message' field.
- Test Detail Page → Action Settings → Failure Message
- Slider View → Action Settings → Failure Message
Using Functionize Actions Instead of Custom Code
How to impliment-
Many common operations performed with JavaScript can be replicated using standard Functionize actions. Below are examples of requirements that can be converted to a codeless approach.
- Get Page Count: To extract the number of pages from a pagination element, use a Get Text action on the element. If the text includes more than just the number, use a Split Variable action to isolate the page count.
- Extract Data from a Specific Row: To get data from a row based on a unique ID, first locate and verify the ID, saving it to a variable. Then, use this variable in subsequent steps to find the correct row and extract the necessary data.
- Compare Two Arrays: To verify if two arrays are identical, use the Verify Equals action. For more complex comparisons, you can use a Loop to iterate through one array and an If Condition to compare each value against the second array.
- Read from a File: Use a Data Source to load data from a file. The data can then be manipulated using actions like Split Variable.
Limitations
Not all custom JavaScript logic can be replaced with codeless actions. For highly complex or dynamic scenarios, custom code remains the recommended solution. Limitations include:
- Complex Data Filtering: Filtering a large or dynamically loaded table (e.g., with infinite scroll) to find all rows matching a specific status is not feasible with built-in actions. Custom JavaScript is better suited for handling such extensive data filtering.
- Advanced File Parsing and Array Creation: Parsing a file to dynamically create multiple, separate arrays based on its content (e.g., sorting IDs by plan type) is beyond the scope of standard actions.
- Comparing Complex Datasets: Finding common values between multiple large datasets, especially when they are sourced from different places (e.g., one from the UI and one from a file), typically requires custom logic that is not available as a built-in action.
Related Information
- Custom Code Action: This action allows you to add JavaScript directly into your test flow. It must return a boolean (
true/false) or a variable value to determine the pass/fail status of the step. - Operators and Regular Expressions: Functionize provides powerful built-in features for handling dynamic data and flexible validations without writing custom scripts. Operators use plain English for comparisons in Verify Actions, and Regular Expressions (regex) allow for advanced pattern matching.
Summary
Custom Code provides powerful ways to extend Functionize beyond no-code boundaries. Use them when built-in Actions are not enough, particularly for:
- Validating dynamic data.
- Handling asynchronous checks.
- Customizing pass/fail conditions.
- Providing clear, contextual result messages.