Flow Control¶
The FlowControl class manages control flow operations including loops, conditions, and data management for test sessions.
Read Data¶
The read_data method loads tabular data from a file path, an environment variable (using the ENV:VAR_NAME form), or a 2D list; applies optional query parts such as select=col1,col2 and filter expressions; and stores the result in the session's elements. For full details on the ENV: prefix, query syntax (including variable resolution ${var}), and all supported file_path forms, see Read Data in Keyword Usage.
optics_framework.api.flow_control.FlowControl ¶
Manages control flow operations (loops, conditions, data) for a session.
condition(*args) ¶
Evaluates conditions and executes corresponding targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args | str | Condition-target pairs, optionally ending with an else target: | () |
Returns:
| Type | Description |
|---|---|
Optional[List[Any]] | Result of the matched target module, or None if nothing matched. |
date_evaluate(param1, param2, param3, param4='%d %B') ¶
Evaluates a date expression based on an input date and stores the result in session.elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param1 | str | The variable name (placeholder) where the evaluated date result will be stored. | required |
param2 | str | The input date string (e.g., | required |
param3 | str | The date expression to evaluate, such as | required |
param4 | Optional[str] | The output format for the evaluated date (default is | '%d %B' |
Returns:
| Type | Description |
|---|---|
str | The resulting evaluated and formatted date string. |
Raises:
| Type | Description |
|---|---|
OpticsError | If the session is not present, the input date format cannot be detected, or the expression format is invalid. Example: |
evaluate(param1, param2) ¶
Evaluates an expression and stores the result in session.elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param1 | str | Variable name to store the result under, e.g. | required |
param2 | str | Expression to evaluate; | required |
Returns:
| Type | Description |
|---|---|
Any | The evaluated result (also stored as a string in session.elements). |
execute_module(module_name) ¶
Executes a module's keywords using the session's keyword_map.
Not exposed on the Optics SDK — session.modules is only populated by CSV/YAML-driven execution; SDK/Robot Framework users should call keywords directly or write a real function/keyword instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_name | str | The module to execute. | required |
Returns:
| Type | Description |
|---|---|
List[Any] | Results of each keyword call in the module, in order. |
invoke_api(api_identifier) ¶
Invokes an API call based on a definition from the session's API data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_identifier | str | API to call, in | required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] |
|
read_data(input_element, file_path, query='') ¶
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_element | str | Variable name where the result is stored (e.g. | required |
file_path | Union[str, List[Any]] | Data source. One of: (1) path to a | required |
query | str | Optional semicolon-separated parts: | '' |
Returns:
| Type | Description |
|---|---|
List[Any] | The stored value as a list (or list of lists for multi-row results). Also writes into |
run_loop(target, *args) ¶
Runs a loop over a target module, either by count or with variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | str | The module name to execute in the loop. | required |
args | str | A single count (e.g. | () |
Returns:
| Type | Description |
|---|---|
List[Any] | One result list per iteration. |