Appearance
File formats
The server, the CLI, the SDK and the test runner read and write these files. Each is JSON or text you can read, diff and edit.
| File | Written by | Where |
|---|---|---|
<name>.saptest.json | sap_record, SAP_RECORD=on; the SDK and the runner as a trace | SAP_RECORD_DIR; traces in the runner's output directory |
<name>.sap.lock.json | the runner, the SDK's verified mode, sap_workflow_run | next to the test; for a workflow, in .workflows/ |
// @sap-workflow | you, or sap_workflow_save | the first line of a *.sap.ts workflow |
.workflows/* | sap_workflow_save, sap_workflow_run, the runner | next to the workflow, in SAP_RECORD_DIR for MCP |
| exports | export, sap_record {"op":"export"} | next to the recording |
Recordings, traces and evidence hold typed values and what the screens showed: treat them like the system's data.
Recordings (.saptest.json)
One JSON object per run, format id sap-gui-test/1. The recorder writes the whole file again after every change (through a .tmp file it then renames), so a crash loses nothing. Each load checks the file against the schema, and every action in it must be one sap_act accepts today. Fields the schema does not name are ignored.
Source: src/record/format.ts, src/record/recorder.ts, src/record/replay.ts.
A recording made on SAP GUI for Windows: display a sales order in VA03 and check its sold-to party (system and numbers are samples).
json
{
"format": "sap-gui-test/1",
"name": "display order",
"description": "Display a sales order and check its sold-to party",
"recorded": { "at": "2026-11-30T09:00:00.000Z", "by": "sap-ui-automation 0.6.0 (cli)", "surface": "sapgui", "system": "DEV", "client": "100" },
"start": { "transaction": "SMEN", "program": "SAPLSMTR_NAVIGATION", "screen": "101", "title": "SAP Easy Access" },
"variables": { "order": { "value": "12345", "description": "a sales order that exists" }, "soldTo": { "value": "100001" } },
"steps": [
{ "action": { "do": "okcode", "value": "/nVA03" }, "at": "2026-11-30T09:00:01.000Z", "ms": 414, "risk": "navigate",
"on": { "transaction": "SMEN", "program": "SAPLSMTR_NAVIGATION", "screen": "101", "title": "SAP Easy Access" },
"after": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" } },
{ "action": { "do": "set", "id": "ctxtVBAK-VBELN", "value": "${order}" }, "at": "2026-11-30T09:00:02.000Z", "ms": 16,
"target": { "id": "wnd[0]/usr/ctxtVBAK-VBELN", "type": "field", "label": "Order", "handle": "ctxtVBAK-VBELN" },
"risk": "navigate",
"on": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" },
"after": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" } },
{ "action": { "do": "key", "key": 0 }, "at": "2026-11-30T09:00:03.000Z", "ms": 434, "risk": "navigate",
"on": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" },
"after": { "transaction": "VA03", "program": "SAPMV45A", "screen": "4001", "title": "Display Standard Order ${order}: Overview" },
"expect": [ { "check": "field", "op": "equals", "value": "${soldTo}",
"id": "wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:SAPMV45A:4701/ctxtKUAGV-KUNNR",
"type": "field", "label": "Sold-To Party", "handle": "ctxtKUAGV-KUNNR" } ],
"note": "the overview shows the order's sold-to party" }
]
}Top level
| Field | Type | Required | Meaning |
|---|---|---|---|
format | "sap-gui-test/1" | yes | the format id; any other value is refused |
name | string, at least one character | yes | the test's name; the file name is its slug (display-order.saptest.json) |
description | string | no | what the test is for, from sap_record {"op":"start","description":...} |
recorded | object | yes | where and when it was recorded (below) |
start | screen reference | yes | the screen the recording started on (below). When the first step is not an okcode /n<transaction>, replay opens /n<start.transaction> first (not SMEN, S000, SESSION_MANAGER, nor on Fiori) and, in strict mode, stops if program and screen differ |
variables | object: name → variable | yes, may be {} | values that change from run to run (below) |
steps | array of steps | yes, may be [] | the actions in order (below); replay refuses a test without steps |
recorded
| Field | Type | Required | Meaning |
|---|---|---|---|
at | string, ISO time | yes | when the recording started |
by | string | no | what wrote it: sap-ui-automation <version>, ... (cli) from the agent CLI, sap-ui-automation sdk <version> from the SDK and runner. No user name |
surface | string | yes | sapgui, webgui or fiori. Replay refuses a session of another surface |
method | string | no | how the surface was read when it is not the usual way: diag for the network reader. Absent for SAP GUI scripting and the other surfaces. On SAP GUI, replay refuses a session read another way, and vbs refuses a diag recording |
system | string | no | the system id |
client | string | no | the client |
Screen references
start, a step's on and a step's after share these fields. A field is absent when the screen did not show it.
| Field | Type | Required | Meaning |
|---|---|---|---|
transaction | string | no | the transaction code |
program | string | no | the program (SAPMV45A) |
screen | string | no | the screen number (4001) |
title | string | no | the window title; may hold ${variables} |
Variables
Each key of variables is a name: letters, digits and _, not starting with a digit. A step writes ${name} where the value stood alone (not inside a longer word or number).
| Field | Type | Required | Meaning |
|---|---|---|---|
value | string | yes | the value in the recording, and the default at replay |
description | string | no | what the value is; a capture writes read from the field Customer after step 3 |
Replay fills ${name} in an action's value, key and node, in check values, and in the status texts and titles it compares; a name with no value is an error. replay --var name=value gives another value; an unknown name is refused.
Steps
| Field | Type | Required | Meaning |
|---|---|---|---|
action | object | no | the action as sap_act takes it, do first. Absent for a step that only checks |
target | object | no | the control the action was done on (below) |
risk | string | no | read, navigate or commit, as the surface rated the action when recorded. Informational: a replay assesses every step again on the live screen, and the guard ignores this label |
note | string | no | what the step is for (sap_record {"op":"note"}); replay's output and most exports show it. The author's text, as are the labels: not checked against SAP |
group | string | no | the sap.step(name, ...) block the action ran in, from SDK code; nested blocks joined with › |
on | object | no | the screen the action was done on: a screen reference plus popup and message (below) |
after | object | no | the screen and status bar the action led to: a screen reference plus status (below) |
expect | array of checks | no | what must hold on the screen the step led to (below) |
capture | array of captures | no | values read from that screen into variables, before the checks run (below) |
ms | number, 0 or more | no | how long the action took, from sending it to SAP's answer, in ms; written on every step recorded from an action. Replay reports a step much slower than this |
at | string, ISO time | no | when the step started; written with ms |
screen | string | no | trace only: the compact screen the action led to, as an agent reads it |
shot | string | no | trace only: a screenshot of that screen, a path relative to the file |
code | string | no | trace only: the SDK line that repeats the action |
target
| Field | Type | Required | Meaning |
|---|---|---|---|
id | string | yes | the control's full SAP id when recorded (wnd[0]/usr/ctxtVBAK-VBELN). When the screen moved it, replay finds it by its last segment or field name, and says so |
type | string | no | its type (field, button, checkbox, tab...) |
label | string | no | its label |
handle | string | no | the shortest tail of the id that named this control alone on that screen. Never for a numbered control (btn[0]). Tidy uses it for short ids |
on and after
| Field | Type | Required | Meaning |
|---|---|---|---|
on.popup | string | no | the popup window in front when the action was done (wnd[1]) |
on.message | boolean | no | true when that popup only informed (text and Continue, no question, no input): a replay may skip the step when SAP does not show it |
after.status | object | no | the status bar the action led to |
after.status.type | string | no | SAP's message type: S, I, W, E or A |
after.status.text | string | yes, in status | the message text; may hold ${variables} |
After each step, replay fails it when the status bar shows E or A, unless after.status has the same type and text, and when transaction, program or screen differ from after where both have them (a note with --loose or "screens":"loose").
expect[] entries
| Field | Type | Required | Meaning |
|---|---|---|---|
check | status, field, title, transaction, text | yes | what is checked: the status bar text, a control's value, the top window's title, the transaction code, or the whole screen |
op | equals, contains, matches | yes | equals compares trimmed texts; matches takes a regular expression |
value | string | yes | what is expected; may hold ${variables} |
id | string | no | for field: the control's full SAP id when recorded |
label | string | no | for field: the control's label |
type | string | no | for field: the control's type; exports read a checkbox or radio as ticked or not |
handle | string | no | for field: the shortest unique id, as in target.handle |
capture[] entries
| Field | Type | Required | Meaning |
|---|---|---|---|
var | string, a variable name | yes | the variable the value goes into |
from | status, field, title | yes | where the value is read |
id | string | no | for field: the control's full SAP id |
label | string | no | for field: the control's label |
pattern | string | no | a regular expression: its first group is the value, else the whole match. Without it, the whole text, trimmed. No match or an empty value fails the step |
handle | string | no | for field: the shortest unique id, as in target.handle |
Traces
A trace is a recording the SDK or the test runner writes: recorded.by is sap-ui-automation sdk <version>, steps have group from sap.step blocks, screen and code, and shot with screenshots on (the runner's use: { screenshots: true }, or screenshots: true in connect's trace; the PNGs are in <name>.trace/ next to the file). Replay runs a trace like a recording; show-trace makes an HTML page of either (Trace viewer).
| Run | Trace file |
|---|---|
connect({ trace: { dir, name } }) | <dir>/<slug of name>.saptest.json |
| the test runner | <outputDir>/<test>/<slug of the title>.saptest.json; outputDir is sap-results by default; a retry writes to <test>-retry<n>/ |
sap_workflow_run | the same, under sap-results/ in SAP_RECORD_DIR |
What a trace adds to the third step of the example (screen shortened):
json
{
"group": "Display the order",
"code": "await sap.key(0);",
"screen": "TRANSACTION VA03 PROGRAM SAPMV45A SCREEN 4001\nWINDOW wnd[0] \"Display Standard Order 12345: Overview\"\nctxtKUAGV-KUNNR field Sold-To Party = \"100001\" (read-only)",
"shot": "display-order.trace/step-3.png"
}Lock files (.sap.lock.json)
A lock holds what SAP answered on passing runs of a *.sap.ts test: per test and sap.step block, the actions with the screen and status bar each led to. Verified mode compares each action's landing with it, with no model (Lock files). Format id sap-gui-lock/1.
Source: src/sdk/lock.ts, src/sdk/verify.ts.
| Test file | Lock file |
|---|---|
orders.sap.ts (no @sap-workflow header) | orders.sap.lock.json next to it; any other x.ts → x.lock.json |
a workflow with a @sap-workflow header, run by the runner | .workflows/<name>-<revision>.sap.lock.json in the test's folder |
a workflow run by sap_workflow_run | SAP_RECORD_DIR/.workflows/<name>-<revision>.sap.lock.json |
connect({ verify: { lock } }) | the path given |
A workflow's lock belongs to one revision of its source (below): editing the file starts a new lock. The example shows one action; the /nVA03 and Enter around it are left out.
json
{
"format": "sap-gui-lock/1",
"tests": {
"display order": {
"verified": { "at": "2026-11-30T09:00:00.000Z", "system": "DEV", "client": "100", "surface": "sapgui", "runs": 3, "lastPass": "2026-11-30T11:00:00.000Z" },
"steps": [
{ "step": "Open the order", "ordinal": 1,
"paths": [[
{ "action": { "do": "set", "id": "ctxtVBAK-VBELN", "value": "12345" },
"target": { "id": "wnd[0]/usr/ctxtVBAK-VBELN", "handle": "ctxtVBAK-VBELN", "type": "field", "label": "Order" },
"risk": "navigate",
"on": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" },
"after": { "transaction": "VA03", "program": "SAPMV45A", "screen": "102", "title": "Display Sales Order: Initial Screen" } }
]] }
]
}
}
}Lock
| Field | Type | Required | Meaning |
|---|---|---|---|
format | "sap-gui-lock/1" | yes | the format id |
tests | object: key → test entry | yes | one entry per test. The runner's key is the test's title path joined with ›, [<project>] before it in a project; connect uses default unless verify.key says otherwise |
Test entry
| Field | Type | Required | Meaning |
|---|---|---|---|
verified | object | yes | where and when the entry was verified (below) |
steps | array of step entries | yes | one per sap.step block run |
verified
| Field | Type | Required | Meaning |
|---|---|---|---|
at | string, ISO time | yes | when the entry was first written |
system | string | no | the system of the last write. Another system: not compared |
client | string | no | the client of the last write |
surface | string | yes | the surface. Another surface: not compared |
runs | integer, 0 or more | yes | passing runs counted when the entry was last written |
lastPass | string, ISO time | yes | the time of that run |
Step entry
| Field | Type | Required | Meaning |
|---|---|---|---|
step | string | yes | the sap.step name, nested blocks joined with ›; "" for actions outside any block |
ordinal | integer, 1 or more | yes | 1 the first time a block of this name runs in the test, 2 the second... |
paths | array of arrays of actions | yes | one list of actions per way through the block that passed (a block with an if has one per branch taken) |
repairs | array of repairs | no | repairs that worked, applied by later runs where the same drift shows again |
Action entry
| Field | Type | Required | Meaning |
|---|---|---|---|
action | object | yes | the action as the code ran it, values as typed in that run |
target | object | no | the control: id (required), handle, type, label, as in a recording's target. Not compared |
risk | string | no | read, navigate or commit, as the surface rated it. The repair rules read it |
on | screen reference | no | the screen it was done on, when it was read. Not compared |
after | screen reference | yes | the screen and status bar it led to |
Action entry on and after
| Field | Type | Required | Meaning |
|---|---|---|---|
transaction, program, screen, title | string | no | as in a recording's screen references |
popup | string | no | the popup window in front (wnd[1]) |
status | object | no | after only: type (optional) and text (required). Only the type is compared |
Repair
| Field | Type | Required | Meaning |
|---|---|---|---|
index | integer, 0 or more | yes | the action of the block it is for, from 0 |
on | string | yes | that action's identity, such as key:0 or set:ctxtVBAK-VBELN |
place | before, instead, after | yes | where the repair's actions run |
actions | array of actions, at least one | yes | what the repair does |
why | string | yes | the reason, as the fallback gave it |
at | string, ISO time | yes | when it was saved |
What a verified run compares, and what a passing run adds
Each action is matched to the lock by its block (step, ordinal), its place in the block and its identity: the verb, the control id, the okcode command (upper case), the app of open, the key number, a dropdown key, row, col, node and how, never a typed value. The screen it led to must have the transaction, program and screen of after where both have them, a popup or none as after.popup says, and no new E or A in the status bar. The title and the status text are not compared.
A difference is settled at the code's next action or read: a branch when the code asks about the screen (sap.at, sap.popup, exists(), dismissInfo, the warning check of save), else drift (a saved repair, then the fallback, else Drift is thrown). An action the lock has nothing for is unverified, not a failure.
At the end of a passing run (sap.lock.finish(true), which the runner calls), each block run adds its actions as a path unless the same path is there (same identities, landings and errors), and repairs that worked join repairs. verified takes this session's system, client and surface, runs plus one and lastPass now. Paths are only added, and the file is written only when the entry changed apart from at, runs and lastPass, so a stable lock does not show in diffs. If another run changed the entry meanwhile, the write fails: run again. On another system or surface the default mode neither compares nor writes; write mode (--update-locks) replaces the entry.
Workflow header (@sap-workflow)
A workflow (Reusable workflows) is a *.sap.ts test whose first line is one JSON object after // @sap-workflow :
ts
// @sap-workflow {"description":"Display a sales order","inputs":{"order":"Sales order number"},"outputs":{"soldTo":"Sold-to party on the overview"},"verifies":"VA03 overview shows the order and its sold-to party"}
import { expect, test } from "sap-ui-automation/test";Source: src/runner/workflow.ts, src/record/code-tools.ts.
| Field | Type | Required | Meaning |
|---|---|---|---|
description | string, not blank | yes | what the workflow does; sap_library searches it |
inputs | object: name → description | yes, may be {} | the values input(name) reads. Every input is a required string, not blank; a missing or unknown input is refused before the run |
outputs | object: name → description | no | the string results output(name, value) returns. A passing sap_workflow_run needs each one, once |
verifies | string, not blank | yes | the SAP result the workflow checks |
Names are letters, digits and _, not starting with a digit. No other field is allowed, and the JSON stays on one line (a line break, U+2028 or U+2029 is refused). A literal input("x") or output("x", ...) must name a declared input or output; sap_workflow_save checks it. Its workflow argument writes the header for you, in place of a header line the code has. A *.sap.ts without the header runs as a plain test: its lock is next to it, and sap_workflow_run's variables override its const vars block.
The .workflows directory
The revision of a workflow is the SHA-256 of its whole source, header included. Locks, receipts and evidence belong to one revision, so an edited workflow is unverified until it passes again. They are in .workflows/ in the workflow's folder (SAP_RECORD_DIR/.workflows/ for MCP), named <name>-<revision>, <name> being the file name without .sap.ts (over 100 bytes: its SHA-256 and a dot). Through MCP the folder is readable by its owner only (0700), receipts and evidence too (0600).
| File | Written by | Holds |
|---|---|---|
<name>-<revision>.sap.lock.json | a passing run | the lock of this revision |
<name>-<revision>.status.json | every sap_workflow_run that started | the receipt: the latest attempt and the last pass (below) |
<name>-<revision>-<digest>.actions.json | sap_workflow_save with source | the reviewed sap_history actions the workflow was made from (below) |
<name>-<revision>.passed | not written by this version | read by sap_library as the last pass when the receipt has none |
Two more folders in SAP_RECORD_DIR: .sap-code-runs/ holds the copy sap_workflow_run runs (imports pointed at this installation) while it runs, and sap-results/ holds its traces.
Receipt
| Field | Type | Required | Meaning |
|---|---|---|---|
latest | object | yes | the latest attempt |
latest.at | string, ISO time | yes | when it ended |
latest.surface | sapgui, webgui, fiori | yes | the session's surface |
latest.write | on, off, confirm | yes | SAP_WRITE then; confirm only in receipts saved before that mode was removed |
latest.status | passed, failed, drift, incomplete, timeout | yes | the outcome. incomplete: nothing failed, but the run did not verify the workflow (no test used a lock, a lock was not written, or not every test passed) |
lastPass | object | no | at, surface and write of the last attempt that passed; kept when a later attempt fails |
Receipts hold no screens, inputs, outputs or errors; sap_library shows them.
Evidence
| Field | Type | Required | Meaning |
|---|---|---|---|
session | string | yes | the session id the actions ran on |
actions | array of actions | yes | the selected actions that did not end in a dispatch error |
entries | array | yes | each selected history entry: action, and outcome, one of {screen, status?}, {error} or {note}; screen has transaction, program, number, title, popup |
digest | string, 64 hex digits | yes | the SHA-256 of the session id and the entries; also in the file name. sap_workflow_save refuses a source whose digest no longer matches |
Evidence keeps typed values as they were typed.
Exports
sap-ui-automation export <file> --to <target> [--out <file>] writes next to the recording (--out - prints), sap_record {"op":"export","name":"...","to":"<target>"} in SAP_RECORD_DIR. Each target turns the recording into one text file. When that file is there already (an earlier export, perhaps edited, or a saved workflow), the export fails and keeps it: --force or "replace": true writes over it. Usage: Recording and replay. The VBS and Playwright files are programs that run outside the guard and outside SAP_WRITE; sap-ts code goes through the guard.
Source: src/record/export/.
| Target | File | For | Cannot express |
|---|---|---|---|
calm | .calm.json | an SAP Cloud ALM manual test case, as the input of a Cloud ALM MCP server's calm_create_test_case tool | nothing runs: actions, checks and captures are words for a tester. Over 30 activities (screens plus Preparation) is refused; titles and texts are cut at Cloud ALM's limits |
vbs | .vbs | SAP GUI scripting (VBScript), for SAP GUI for Windows | a Fiori or diag recording is refused. Keys without a virtual key number, steps with a short id only, click, scroll, open, text checks and field checks without a full id become ' TODO lines. It answers no popup the recording does not have |
playwright | .spec.ts | a Playwright test for Web GUI (@playwright/test) | click, combo, tree, grid, toolbar, scroll, open, menu entries, keys with no browser key and short ids become test.fixme. Fiori output takes set, press, click, select and named keys only, has no field, status or transaction checks, and has not been run against a launchpad |
playwright-sap | .psap.spec.ts | the same with playwright-sap's locateSID | as playwright |
sap-ts | .sap.ts | a test for this package's runner, written with its scripting API | the checks replay makes after every step (no error, the recorded screen); a lock adds them when the test runs. Popups and screens SAP shows for some data only, beyond a recorded information popup: tidied code (sap_record {"op":"code","tidy":true}, an answer, not a file) writes them as conditions |
gherkin | .feature | a Given / When / Then step list, for Cucumber-style tools and for reading | no step definitions and no ids. Variables are one row of Examples with the recorded values; captures are a line to note a value |
