Variable FZE Object

Functionize Variable FZE Object Overview

Variables are stored and made available to JS expressions and scripts, executed in the browser by Functionize, in the form of a variable called fze in the scope of those expressions and scripts. That object itself is read only and has the following attributes:

Objects

fze.local - Object, Read/Write

  • This Object is for local variables which need to be available during and after the current step in a single test execution and they will be visible in FE, but will not be available in future runs or other tests in the project

fze.project - Object, Read/Write

  • Like local variables, project variables can be used to store data by setting attributes on them, unlike local variables though, project variables are from previous runs, and/or project settings are loaded at the beginning of the test, and changes made to them will persist into future runs and project variables are shared across all tests in a project, so be careful to consider how they may be overwritten, especially in orchestration runs

fze.team - Object, Read/Write

  • Team variables are just like project variables, except that their scope is for an entire team, not just a single project and we recommend using these sparingly, primarily for configuration data, like an email address or phone number that you might use across all your tests.

fze.action("123_ACTION_ID_HERE") Step Object, Read Only

  • This method returns the Step Object from the most recent step that matches a given ActionID, if one exists, see below for the contents of the Step Object

fze.step Array of Step Objects, Read Only

  • This list contains a Step Object for each step executed so far in this test and the steps ordered descending in chronological order

fze.attributes Object, Read Only

  • Attributes contain an object of all attributes of the currently selected element, this includes computed attributes, which are accessible like c_background-color and this object is not necessarily populated until a specific attribute is requested

fze.clipboard String, Read Only

  • This read only string value will be populated on each step with the current value of the test machine’s clipboard and this is useful for verifying the value of text added to the clipboard by the app being tested

fze.resource Object, Read Only

  • This object contains network call objects that were made since the most recent PageInit, if the flag to provide them is enabled in the test, the resource objects are mapped per URL - if one URL is used multiple times since the most recent PageInit step, all but the first request will have numerals appended to their URL - see below for an example of what could be contained in the resource object

fze.date Object, Read Only

  • This is a JS date object created at the time of script injection, it is provided as a static time to use when multiple calls to a current Date are needed in custom code and it is analogous to a local variable like let currentDate = new Date();

Functions

fze.randomPhone(format)Function

  • Generates a random phone number in a given format and the format can be any string, and all X characters will be replaced with random integer digits
    For example: +1 (415) XXX-XXXX could return something like +1 (415) 765-4321 or +1 (415) 112-3581, if no format is provided, the default XXX-XXX-XXXX is used.

fze.randomNumber(length)Function

  • Generates a random integer number of the given length and defaults to 3 digits

fze.randomNumberString(length)Function

  • Generates a string consisting only of integer digits of a given length and defaults to 10 characters

fze.numberInRange(min,max)Function

  • Generates a random number inside the provided range and min and max are required arguments

fze.randomString(length)Function

  • Generates a random string of alpha numeric characters (upper and lower case) of the specified length. Defaults to 10 characters

fze.randomEmail(domain)Function

  • Generates a random email at a specified domain. Defaults to example.com if no domain is provided and email addresses will be a random string of characters between 6 and 8 characters long (inclusive)

fze.randomDoB(minimumAge, maximumAge)Function

  • Generates a JS Date object for the birthdate of someone between the minimumAge and the maximumAge provided and if multiple values from that date, like day, month, and year are needed, the object should be saved in a variable and referred to from there

All values written to any parts of the fze object will be serialized and deserialized between each step, so non-privative types will become objects or strings, some values may be typecast before you use them next, and object references will be come dereferenced. Generally, variables are intended to be used as strings:string key pairs.

Step Object

Step Objects represent a step that was executed earlier in the test execution and each has the following attributes

actionIdString

  • The Action ID of this step

stepNumber Number

  • Denotes which step this was in execution and StepNumbers are 0-indexed with the first page init being step number 0

url String

  • The active page url when this step was executed

resultCode String

  • The string code for the step’s result:
    • E Error

    • N Fail

    • Y Pass

    • W Warning

    • S Suppress (Optional and failed, or skipped step)

textString, Optional

  • The text of the step’s element

valueString, Optional

  • The value of the step’s element

attributes Object

  • The filtered set of attributes gathered from this step’s element, it does not include computed attributes and this object is not necessarily populated until a specific attribute is requested

elementWidthString, Optional

  • The width in pixels of the step’s element

elementHeightString, Optional

  • The height in pixels of the step’s element

Example Use Cases

fze.local.thisStepComputedWidth = fze.attributes.c_width

  • This sets a local variable equal to the value of the current step’s element’s computed width, if it exists

fze.project.valueToIncrement += 1

  • Increments the value of the project variable valueToIncrement by 1 and this change will be available later in this test and in future runs of any test in the same project

fze.local.stepFourClipboard = fze.clipboard

  • Save for later use the value of the clipboard during the current step

fze.action("1641833968712_2E6FFQP26P").attributes.href

  • If used in an expression or verifyVariable action, this will evaluate to the href attribute of the element from the most recent action with ID 1641833968712_2E6FFQP26P

Notes

  • All expressions or scripts (custom code, set variable, and verify variable actions, as well as the PreAction and Post Action scripts of each steps) have variables available to them as long as fze appears somewhere in the expression/script

  • Team and project variables are fetched at the beginning of a test. If conflicting changes are made to project or team variables during two or more tests running at the same time, whichever test finishes last will overwrite the values of the earlier test and it is inadvisable to write to the same project variable in multiple tests that could be run in parallel

  • It is possible to write to some read only objects in fze however those changes will be lost by the next step at the latest

  • Just as in JS, attributes of Objects can be accessed with either dot fze.attributes.href or array notation fze.attributes["href"] with the advantage of the latter being that the attribute name can be determined dynamically

  • Because local and project variables are logged out in the slider view, you can debug by saving objects to them. For example, to check which header fields are available in a network resource object, you might use: fze.local.R2 = fze.resource['https://functionizeapp.com/testsites/anaqa/'].requestHeaders;

{
"http://apps.qa01.trustmineral-staging.com/auth/login":
{
"formData":
[],
"method": null,
"queryParams":
{
"from": "/dashboard"
},
"requestBody": "",
"requestHeaders":
{
"Accept": "text/html,application/xhtml%2Bxml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "en-US,en;q=0.9",
"Sec-Ch-Ua": " Not A;Brand;v=99, Chromium;v=102, Google Chrome;v=102",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "Linux",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36 Functionize",
"Via": "1.1 martian-a557ff3b4f16e888b294"
},
"responseBody": "",
"responseHeaders":
{
"Warning": "199 martian proxyconnect tcp: dial tcp 10.240.0.46:3128: connect: connection timed out Tue, 28 Jun 2022 01:08:32 GMT"
},
"status": 502,
"statusCode": 502,
"url": "http://apps.qa01.trustmineral-staging.com/auth/login"
},
"http://apps.qa01.trustmineral-staging.com/auth/login_1":
{
"formData":
[],
"method": null,
"queryParams":
{
"from": "/dashboard"
},
"requestBody": "",
"requestHeaders":
{
"Accept": "text/html,application/xhtml%2Bxml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "en-US,en;q=0.9",
"Sec-Ch-Ua": " Not A;Brand;v=99, Chromium;v=102, Google Chrome;v=102",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "Linux",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36 Functionize",
"Via": "1.1 martian-a557ff3b4f16e888b294"
},
"responseBody": "",
"responseHeaders":
{
"Warning": "199 martian proxyconnect tcp: dial tcp 10.240.0.153:3128: connect: connection timed out Tue, 28 Jun 2022 01:09:04 GMT"
},
"status": 502,
"statusCode": 502,
"url": "http://apps.qa01.trustmineral-staging.com/auth/login_1"
}
}