manage_session
Manage Robot Framework session lifecycle: initialize sessions, import libraries and resources, set variables, and control multi-test workflows with start/end test actions.
Instructions
Manage session lifecycle: initialize, configure libraries/variables, and organize tests.
For a NEW scenario, prefer analyze_scenario — it is the front door that CREATES the session (and auto-configures libraries). Use manage_session for explicit session ops on an existing session (importing extra libraries/resources/variables, multi-test structure). Do NOT call action="init" right after analyze_scenario — the session already exists; that only causes redundant churn.
Workflows: Single test: analyze_scenario -> execute_step (repeat) -> build_test_suite Multi-test: analyze_scenario -> set_suite_setup -> start_test -> execute_step (repeat) -> end_test -> start_test -> ... -> build_test_suite (action="init" is the explicit alternative when you are NOT starting from analyze_scenario, e.g. driving a bare session directly.)
Actions and parameters (session_id is always required):
init - Create session and load libraries (explicit entry; for a new
scenario prefer analyze_scenario instead).
Params: libraries (list of library names),
variables (dict or list to pre-set).
import_library - Add a library to an existing session.
Params: library_name, args (constructor args), alias.
import_resource - Import a Robot Framework resource file.
Params: resource_path, args.
set_variables - Set variables in the session.
Params: variables (dict {"NAME": "value"} or list ["NAME=value"]),
scope ("test" | "suite" | "global", default "suite").
import_variables - Load variables from a Python variable file.
Params: variable_file_path, args (passed to get_variables()).
start_test - Begin a named test (enables multi-test mode). Local mode only.
Params: test_name (required),
test_documentation, test_tags,
test_setup (dict {"keyword": "...", "arguments": [...]}),
test_teardown (same format as test_setup).
Alias: start_task.
end_test - End the current test. Local mode only.
Params: test_status ("pass" or "fail", default "pass"),
test_message (optional error description).
NOTE: test_status and test_message are session tracking metadata.
They do NOT affect the .robot file generated by build_test_suite.
Alias: end_task.
add_data_row - Add a data row to the current data-driven (template) test.
Requires an active test with template set via start_test.
Params: args (list of values matching the template keyword's [Arguments]).
Alias: data_row.
Example:
manage_session(action="start_test", test_name="Cart Test",
template="Add And Verify Product")
manage_session(action="add_data_row", args=["Backpack", "1", "$29.99"])
manage_session(action="add_data_row", args=["Bike Light", "2", "$39.98"])
manage_session(action="end_test")
The data rows appear under [Template] in the generated .robot file.
list_tests - List all tests in the session with their status and step counts.
Params: (none).
set_suite_setup - Set a suite-level setup keyword (appears in *** Settings ***).
Params: keyword (required), args (keyword arguments).
set_suite_teardown - Set a suite-level teardown keyword (appears in *** Settings ***).
Params: keyword (required), args (keyword arguments).Returns: Dict with success, session_id, and action-specific details. On failure: error and guidance fields are present.
Examples: Initialize session with libraries: manage_session(action="init", session_id="s1", libraries=["Browser", "BuiltIn", "Collections"])
Set suite-level variables:
manage_session(action="set_variables", session_id="s1",
variables={"BASE_URL": "https://example.com", "TIMEOUT": "30"})
Import a library with constructor arguments:
manage_session(action="import_library", session_id="s1",
library_name="Browser", args=["chromium"])
Load a Python variable file:
manage_session(action="import_variables", session_id="s1",
variable_file_path="config/variables.py",
args=["production", "secret_key"])
Start a named test (multi-test mode):
manage_session(action="start_test", session_id="s1",
test_name="Login Test", test_tags=["smoke"],
test_setup={"keyword": "Open Browser", "arguments": ["chromium"]})
End the current test:
manage_session(action="end_test", session_id="s1")
Set suite setup (for generated .robot file):
manage_session(action="set_suite_setup", session_id="s1",
keyword="New Browser", args=["chromium"])
Set suite teardown:
manage_session(action="set_suite_teardown", session_id="s1",
keyword="Close Browser")Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| alias | No | ||
| scope | No | suite | |
| action | Yes | ||
| keyword | No | ||
| profile | No | ||
| scenario | No | ||
| template | No | ||
| libraries | No | ||
| test_name | No | ||
| test_tags | No | ||
| variables | No | ||
| model_name | No | ||
| model_tier | No | ||
| session_id | No | ||
| test_setup | No | ||
| test_status | No | pass | |
| library_name | No | ||
| test_message | No | ||
| tool_profile | No | ||
| resource_path | No | ||
| test_teardown | No | ||
| test_documentation | No | ||
| variable_file_path | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||