Keyword Usage¶
This document outlines the available keywords for the Optics Framework, which can be used in the modules.csv file to define test steps. Keywords are derived from the framework's Python API, with method names converted to a space-separated format (e.g., press_element becomes Press Element). Each keyword corresponds to a specific action, verification, or control flow operation. Below, each keyword includes detailed parameter explanations to guide their usage.
Keyword data sources¶
- Element-based keywords (Press Element, Assert Elements, Type Text, Validate Element, etc.) use element data from element files (CSV with columns such as
element_name/element_id, or YAML with anelementskey). Element names in test steps refer to these definitions. - Invoke API uses API definition data from API YAML files (top-level
apiorapis). It does not use element files. You reference an API by the identifiercollection.api_name.
Action Keywords¶
These keywords handle interactions with the application, such as clicking, swiping, and text input.
Press Element¶
Presses a specified element on the screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target to press. Can be: • Text: A string to locate via text detection (e.g., "Home", ${Home_text})• XPath: An XPath expression for Appium/Selenium (e.g., //android.widget.Button[@resource-id="id"])• Image: A filename of an image in input_templates/ (e.g., "home.png", ${Home_image}) | - |
repeat | Optional | Number of times to press the element (integer) | 1 |
offset_x | Optional | Horizontal offset in pixels from the element's center (integer) | 0 |
offset_y | Optional | Vertical offset in pixels from the element's center (integer) | 0 |
index | Optional | Index of the element if multiple matches are found (integer, 0-based) | 0 |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for logging or triggering events (e.g., "click_home") | - |
Example:
Press By Percentage¶
Presses at percentage-based coordinates on the screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
percent_x | Required | X-coordinate as a percentage of screen width (float, 0.0 to 1.0, e.g., 0.5 for 50%) | - |
percent_y | Required | Y-coordinate as a percentage of screen height (float, 0.0 to 1.0) | - |
repeat | Optional | Number of times to press (integer) | 1 |
event_name | Optional | A string identifier for the press event (e.g., "center_press") | - |
Example:
Press By Coordinates¶
Presses at absolute coordinates on the screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
coor_x | Required | X-coordinate in pixels (integer, e.g., 500) | - |
coor_y | Required | Y-coordinate in pixels (integer, e.g., 800) | - |
repeat | Optional | Number of times to press (integer) | 1 |
event_name | Optional | A string identifier for the press event (e.g., "tap_event") | - |
Example:
Detect And Press¶
Presses an element if it appears within timeout. When it never appears the press is skipped and the keyword still passes, so use it for optional taps (e.g. dismissing a popup that may not show) and Press Element when the target must be present.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to detect and press (Image template, OCR template, or XPath) | - |
timeout | Optional | Timeout for the detection operation in seconds (integer) | 30 |
event_name | Optional | A string identifier for the press event | - |
Example:
Select Dropdown Option¶
Opens a dropdown and selects one of its options, scrolling through the list if needed.
Presses the dropdown element to open it. If option is already visible, presses it directly. Otherwise, diffs the interactive elements captured before and after opening to find the dropdown's scrollable list container, then scrolls within that container until option appears or the list stops changing. Raises an error (E0201) if option is never found within timeout seconds, preventing a silent mis-selection. Falls back to a single-screen check (no scrolling) when page source, or a list-like container, isn't available.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The dropdown element (Image template, OCR template, or XPath) | - |
option | Required | The option to select (visible label text, OCR template, or XPath) | - |
timeout | Optional | Seconds to keep scrolling through the dropdown list before failing | 30 |
event_name | Optional | A string identifier for the selection event | - |
Example:
Swipe¶
Performs a swipe action in a specified direction from given coordinates. direction is the way the finger moves: up drags bottom to top, which reveals content further down (the opposite of Scroll, where down reveals content further down).
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
coor_x | Required | X coordinate of the swipe starting point (integer) | - |
coor_y | Required | Y coordinate of the swipe starting point (integer) | - |
direction | Optional | The swipe direction: up, down, left, or right | right |
swipe_length | Optional | The length of the swipe in pixels (integer) | 50 |
event_name | Optional | A string identifier for the swipe event | - |
Example:
Swipe By Percentage¶
Performs a swipe action in a specified direction by percentage of the screen (0-100). direction is the way the finger moves: up drags bottom to top, which reveals content further down (the opposite of Scroll, where down reveals content further down).
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
percent_x | Required | X position of the swipe start as a percentage of screen width (integer, 0-100) | - |
percent_y | Required | Y position of the swipe start as a percentage of screen height (integer, 0-100) | - |
direction | Optional | The swipe direction: up, down, left, or right | right |
swipe_length | Optional | Length of the swipe as a percentage of the screen (integer, 0-100) | 50 |
event_name | Optional | A string identifier for the swipe event | - |
Example:
Swipe Until Element Appears¶
Swipes in a specified direction until an element appears. Raises an error if the element does not appear within the timeout.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element to find (Image template, OCR template, or XPath) | - |
direction | Required | The swipe direction: up, down, left, or right | - |
timeout | Required | Maximum time in seconds to keep swiping before raising an error (integer) | - |
event_name | Optional | A string identifier for the swipe event | - |
Example:
Swipe From Element¶
Performs a swipe action starting from a specified element.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to swipe from (Image template, OCR template, or XPath) | - |
direction | Required | The swipe direction: up, down, left, or right | - |
swipe_length | Required | The length of the swipe in pixels (integer) | - |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for the swipe event | - |
Example:
Scroll¶
Scrolls the current view one step. direction names the way you move through the content: down reveals content further down. Every driver supports up/down; left/right work only on Selenium. The keyword passes whether or not the view moved.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
direction | Required | up or down (left/right on Selenium only) | - |
event_name | Optional | A string identifier for the scroll event | - |
Example:
Scroll Until Element Appears¶
Scrolls in a specified direction until an element appears. Raises an error if the element does not appear within the timeout.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element to find (Image template, OCR template, or XPath) | - |
direction | Required | The scroll direction: up, down, left, or right | - |
timeout | Required | Maximum time in seconds to keep scrolling before raising an error (integer) | - |
event_name | Optional | A string identifier for the scroll event | - |
Example:
Scroll From Element¶
Performs a scroll action starting from a specified element.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to scroll from (Image template, OCR template, or XPath) | - |
direction | Required | The scroll direction: up, down, left, or right | - |
scroll_length | Required | The length of the scroll in pixels (integer) | - |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for the scroll event | - |
Example:
Enter Text¶
Enters text into a specified element. When the element is a caption or label rather than a field, the text goes into the field it names: on the web its <label> control or the one field labelled with the caption's text, on Android and iOS the one field whose hint or accessibility label holds the caption's text, and otherwise the only field next to it. When several fields fit, the step fails instead of guessing.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element (Image template, OCR template, or XPath) | - |
text | Required | The text to be entered | - |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for the input event | - |
Example:
Enter Text Direct¶
Types text into the element that has focus, without targeting a specific element. It does not wait for a field to be ready. To type into a known field, use Enter Text with the field's locator; on the web it waits until the field accepts input.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
text | Required | The text to be entered | - |
event_name | Optional | A string identifier for the input event | - |
Example:
Enter Text Using Keyboard¶
Enters text or presses a special key using the keyboard. Supports special keys like <enter>, <tab>, etc.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
text_input | Required | The text or special key identifier to send (e.g., "hello" or " | - |
event_name | Optional | A string identifier for the keyboard event | - |
Example:
Enter Number¶
Enters a specified number into an element.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element (Image template, OCR template, or XPath) | - |
number | Required | The number to be entered | - |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for the input event | - |
Example:
Press Keycode¶
Presses a specified keycode (useful for Android keycodes like BACK, HOME, etc.).
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
keycode | Required | The keycode to be pressed (e.g., "4" for BACK, "3" for HOME) | - |
event_name | Optional | A string identifier for the keycode event | - |
Example:
Clear Element Text¶
Clears text from a specified element.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element (Image template, OCR template, or XPath) | - |
aoi_x | Optional | X percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_y | Optional | Y percentage of Area of Interest top-left corner (0-100, float) | 0 |
aoi_width | Optional | Width percentage of Area of Interest (0-100, float) | 100 |
aoi_height | Optional | Height percentage of Area of Interest (0-100, float) | 100 |
event_name | Optional | A string identifier for the clear event | - |
Example:
Get Text¶
Gets the text from a specified element, including a CSS or DOM XPath locator in a mobile web page through appium_web. For a text field (input or textarea) or a dropdown (select) on the web, it returns its current value.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The target element (Text, XPath, or a web locator) | - |
Example:
Note: To keep the text for later steps, add store_as=<name>, then reference it as ${name}:
Sleep¶
Sleeps for a specified duration.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
duration | Required | The duration of the sleep in seconds (integer) | - |
Example:
Execute Script¶
Executes JavaScript/script in the current context. Supports both plain script strings and JSON format with arguments.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
script_or_json | Required | The JavaScript code/script command, or a JSON string containing {"script": "...", "args": {...}} or {"script": "..."} | - |
event_name | Optional | A string identifier for the script execution event | - |
Example:
Verification Keywords¶
These keywords handle verification and validation operations.
Assert Equality¶
Compares two values for equality and fails the step when they differ. Both values are converted to strings and stripped of leading/trailing whitespace before comparison. Either value can be a ${variable} reference.
Usage note: Evaluate writes its result directly into session.elements, so ${var} from Evaluate can be passed straight into Assert Equality.
No expression evaluation: Assert Equality only resolves ${var} references to their stored string value, then compares the two resulting strings as-is — it does not evaluate anything as Python. Quote characters you type are compared literally, not stripped. So a stored value of 9.99 must be compared against the bare literal 9.99 (not '9.99').
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
output | Required | The actual value to check — typically a ${variable} already populated by Evaluate, or a value read back from a keyword like Get Text | - |
expression | Required | The expected value | - |
event_name | Optional | A string identifier for the event | - |
Example (direct literal comparison):
Example (chained after Evaluate):
To check the text an element shows, use Assert Text.
Assert Text¶
Waits until the text of an element equals the expected text, and fails the step if it does not. For a text field (input or textarea) on the web, it compares the field's current value. Spaces at the start and end are ignored on both sides.
If the element is not found, the step fails with an element-not-found error, so the next value of a ${name} element is tried. If the element shows a different text at the timeout, the step fails and the error gives the text that the element shows.
The element must be in the UI tree. An element found only by OCR or image fails the step at once.
An expected value with the @: prefix is compared without the prefix, and the error shows **** in place of both texts.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to read (Text, XPath or CSS) | - |
expected | Required | The text to expect | - |
timeout | Optional | The time to wait for the text in seconds | 10 |
event_name | Optional | A string identifier for the event | - |
Example:
Assert Text,//android.widget.TextView[@resource-id="price_label"],9.99
Assert Text,${state_field},${state},5
Validate Element¶
Verifies the specified element is present on the screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to be verified (Image template, OCR template, or XPath) | - |
timeout | Optional | The time to wait for verification in seconds (integer) | 10 |
rule | Optional | The rule used for verification: all or any | all |
event_name | Optional | The name of the event associated with the verification | - |
Example:
Is Element¶
Checks if an element is in a given state: visible, invisible, enabled, disabled, checked, or unchecked. Raises an error if the element's actual state does not match the expected state.
- visible / invisible — asserts presence or absence of the element on screen within the timeout.
- enabled / disabled — locates the element and checks its interactive state via the accessibility tree. On the web,
aria-disabled="true"counts as disabled. - checked / unchecked — locates a checkbox, radio button or switch and checks whether it is on. On the web,
aria-checkedcounts too.
OCR and image matches are not supported for the enabled, disabled, checked and unchecked states.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
element | Required | The element to check (Image template, OCR template, or XPath) | - |
element_state | Required | Expected state: visible, invisible, enabled, disabled, checked, or unchecked | - |
timeout | Required | Time to wait for the element in seconds (integer) | - |
event_name | Optional | A string identifier for the event | - |
Example:
Is Element,login_button.png,visible,10,check_login_visible
Is Element,//android.widget.Button[@text="Submit"],enabled,5,check_submit_enabled
Is Element,loading_spinner.png,invisible,15,wait_for_load
Is Element,css=#accept_terms,checked,5
Assert Presence¶
Asserts the presence of elements. Can check multiple elements with pipe separator (|).
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
elements | Required | Comma-separated or pipe-separated string of elements to check (e.g., "button1.png|button2.png") | - |
timeout_str | Optional | The time to wait for the elements in seconds (integer) | 30 |
rule | Optional | The rule for verification: any (at least one) or all (all must be present) | any |
event_name | Optional | The name of the event associated with the assertion | - |
Example:
Assert Visibility¶
Asserts that elements are actually rendered/visible on screen right now — distinct from Assert Presence, which reports found even for elements that exist in the page/DOM but are off-screen (e.g. not yet scrolled into view). Can check multiple elements with pipe separator (|).
Driver support: Appium (Android and iOS). Selenium and Playwright do not yet implement this keyword and raise an error if used — support is pending fixes to unrelated pre-existing bugs in those drivers.
Android note: elements scrolled out of view are omitted entirely from the page source by default on Android, so this keyword can't tell "off-screen" from "doesn't exist" for them unless allowInvisibleElements: true is set under appium:settings — see Appium configuration.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
elements | Required | Comma-separated or pipe-separated string of elements to check (e.g., "button1.png|button2.png") | - |
timeout_str | Optional | The time to wait for the elements to become visible, in seconds (integer) | 30 |
rule | Optional | The rule for verification: any (at least one) or all (all must be present) | any |
event_name | Optional | The name of the event associated with the assertion | - |
Example:
Validate Screen¶
Waits for elements and reports whether they appeared. Similar to Assert Presence, but it never fails the step: when the elements are not found, it logs that and the run continues. Use Assert Presence when the check must fail the test.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
elements | Required | Comma-separated or pipe-separated string of elements to verify | - |
timeout | Optional | The time to wait for verification in seconds (integer) | 30 |
rule | Optional | The rule for verification: any or all | any |
event_name | Optional | The name of the event associated with the verification | - |
Example:
Capture Screenshot¶
Captures a screenshot of the current screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
event_name | Optional | The name of the event associated with the screenshot capture | - |
Example:
Capture Pagesource¶
Captures the page source of the current screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
event_name | Optional | The name of the event associated with the page source capture | - |
Example:
Get Interactive Elements¶
Retrieves a list of interactive elements on the current screen.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
filter_config | Optional | Optional list of filter types (e.g., "buttons,inputs") | - |
Example:
Get Screen Elements¶
Captures a screenshot and retrieves interactive elements from the current screen in a single call. Returns a dict with a base64-encoded screenshot and a list of elements.
Parameters:
None.
Example:
App Management Keywords¶
These keywords handle application lifecycle operations.
Launch App¶
Launches the specified application.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
app_identifier | Optional | The app identifier (package name for Android, bundle ID for iOS) | - |
app_activity | Optional | The app activity (Android only) | - |
event_name | Optional | The event triggering the app launch | - |
Example:
Start Appium Session¶
Starts an Appium session. This is typically called automatically during setup.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
event_name | Optional | The event triggering the session start | - |
Example:
Launch Other App¶
Starts another application.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
app_name | Required | The package name or bundle ID of the application | - |
event_name | Optional | The event triggering the app start | - |
Example:
Close And Terminate App¶
Tears down the active driver session and flushes all pending events. The exact behaviour depends on the configured driver (Appium, Selenium, Playwright, BLE) but in all cases the driver reference is released after this call.
Parameters:
None
Example:
Force Terminate App¶
Forcefully terminates the specified application.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
app_name | Required | The name of the application to terminate | - |
event_name | Optional | The event triggering the forced termination | - |
Example:
Get App Version¶
Gets the version of the application.
Parameters:
None
Example:
Get Driver Session Id¶
Returns the current driver session ID, if available.
Parameters:
None
Example:
Flow Control Keywords¶
These keywords handle control flow operations like loops, conditions, and data manipulation. Module execution is performed by the runner when it runs test-case steps; the Optics API does not expose user-facing "Initialise Setup" or "Execute Module" keywords.
Run Loop¶
Runs a loop over a target module, either by count or with variables.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
target | Required | The module name to execute in the loop | - |
args | Variable | Either a count (integer) or variable-iterable pairs: • Count: ["5"] - runs 5 times• Variables: ["${var1}", "value1\|value2\|value3", "${var2}", "a\|b\|c"] - iterates over values | - |
Example (by count):
Example (with variables):
Condition¶
Evaluates conditions and executes corresponding targets. Supports both module-based and expression-based conditions.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
args | Variable | Condition-target pairs, optionally ending with an else target: • ["condition1", "target1", "condition2", "target2", "else_target"]• Conditions can be module names (prefixed with ! to invert) or expressions | - |
Example (module condition):
Example (expression condition):
Example (with else):
Read Data¶
Reads tabular data from a CSV file, JSON file, environment variable, or a 2D list, applies optional filtering and column selection, and stores the result in the session's elements.
For the programmatic API and full parameter details, see Flow Control in the API reference.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
input_element | Required | The variable name where data will be stored. Prefer the form ${name} (e.g. ${data}). If another form is used, the value is still stored under that name (a warning may be logged). | - |
file_path | Required | The data source. One of: • File path: Path to a .csv or .json file (relative paths are resolved from the project path). Only these extensions are supported.• Environment variable: Use the prefix ENV: followed by the variable name. Example: ENV:APP_CONFIG reads the env var APP_CONFIG. The value is interpreted as: (1) if it looks like JSON (starts with [, {, or "), it is parsed as JSON and objects/arrays are normalized to a table; (2) otherwise it is parsed as CSV if valid; (3) otherwise the whole value is stored as a single string. optics serve and optics mcp refuse ENV: from their callers, since they have no caller authentication: use it in project runs or the Python API.• 2D list: Only when using the Python API: a list whose first row is headers and following rows are data (e.g. [["col1","col2"],["a","b"]]). Not passable as a literal in CSV test steps; see Library Usage for programmatic use. | - |
query | Optional | Semicolon-separated parts. Each part is either: • Column selection: select=col1,col2,... (comma-separated column names).• Filter: Comparisons of columns with values, joined with and/or/not (or &/|/~), plus col in [...]; quote a column name with spaces in backticks. E.g. status=='active', count>10. Multiple filter parts are combined with and.Any ${varname} in the query is replaced from session.elements before evaluation (e.g. role=='${expected_role}'). | "" |
Example (CSV file):
Example (with filter):
Example (environment variable):
Example (query with variable):
Note: Inline list data (e.g. a 2D list) is supported only when calling the Python API; see Library Usage for examples.
Evaluate¶
Evaluates an expression and stores the result in session.elements under the given variable name.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
param1 | Required | The variable name where the result will be stored (e.g., ${result}) | - |
param2 | Required | The expression to evaluate (can use variables like ${var1} + ${var2}) | - |
How param2 is evaluated:
- Every
${var}inparam2is first replaced, as plain text, with the variable's stored string value — before anything is evaluated as Python. - The result of that substitution is then computed by a restricted evaluator that runs no Python. Only arithmetic (
+ - * / % **), comparisons (> < >= <= == !=), boolean logic (and or not), a ternary... if ... else ..., and literallist/tuplevalues are allowed. Anything else (function calls, attribute access, imports, f-strings, etc.), and expressions too large to compute, are rejected withCode.E0406. - Because the substitution is textual and unquoted, a
${var}that holds text must be wrapped in quotes inside the expression (e.g.'${name}'), otherwise the substituted word is treated as an unknown name and raisesCode.E0403. A${var}that holds a number does not need quotes. - The final result is stored via
str(result), so even numbers and booleans end up as strings insession.elements(e.g.True→"True"). param1must be in${name}form; if it isn't, a warning is logged and the raw string is used as the variable name as-is.
Example (numeric arithmetic):
${sum} → 8
Example (comparison):
${is_valid} → True
Example (string literal):
Wrap plain text in quotes so it's evaluated as a Python string, not as bare identifiers:
${greeting} → hello world
Example (concatenating a stored text variable):
${name} holds text, so it must be quoted inside the expression once substituted:
${message} → Hello, Alice
Example (ternary if/else):
${result} → Pass
Example (list literal):
${numbers} → [1, 2, 3, 4]
Date Evaluate¶
Evaluates a date expression based on an input date and stores the result in session.elements.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
param1 | Required | The variable name where the evaluated date result will be stored (e.g., ${tomorrow}) | - |
param2 | Required | The input date string (e.g., "04/25/2025" or "2025-04-25"). Format is auto-detected | - |
param3 | Required | The date expression to evaluate, such as "+1 day", "-2 days", or "today" | - |
param4 | Optional | The output format for the evaluated date (default is "%d %B", e.g., "26 April") | %d %B |
Example:
Example (with custom format):
Add API¶
Adds or updates API definitions in the current session by loading from a file path or a dictionary. Use this when not using the runner's auto-discovery (e.g. when driving the framework programmatically). The supplied data replaces the session's API data.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
api_data | Required | Either a path to an API YAML file, or a dictionary with the same structure (top-level api key with collections, etc.) | - |
Example (file path):
Example (programmatic): Pass a dict with an api key holding the collection/endpoint definitions. Relative paths are resolved against the project path when a string is given.
Invoke API¶
Invokes an API call based on a definition from the session's API data.
A run needs no driver when the selected test cases use only flow-control keywords (Invoke API, Evaluate, Condition, Read Data, ...) and modules made of them. Set every driver_sources entry to enabled: false and run it with optics execute.
Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
api_identifier | Required | The API identifier in format collection.api_name | - |
Example:
Extracting response values
expected_result.extract maps a variable name to a JSONPath expression evaluated against the JSON response; the value lands in the session's ${variable} namespace.
The bare form (resultObj.total) still works and may include JSONPath array expressions.
Checking the response status
When expected_result.expected_status is set, Invoke API fails if the response has a different HTTP status. The check runs before any value is extracted.
Data source: API definition YAML
Invoke API does not use element files. It uses API definition YAML files only. The format is different from element CSV/YAML: definitions live under a top-level api (or apis) key, with collections → each collection has base_url, global_headers, and apis → each API has endpoint, request (e.g. method, headers, body), and optionally expected_result, extract, and so on.
How API definitions reach the session:
- CLI/runner: YAML files under the project that contain a top-level
apiorapiskey are auto-discovered and loaded as API data. - Programmatic: The Add API keyword can load from a file path or a dict to set or replace session API data.