Cheatography
https://cheatography.com
Quick reference for OKW REST API testing keywords (Robot Framework). Covers the complete test lifecycle: Start, Scope, Input, Action, Verify, Memorize, Stop. Designed for AI-friendly test generation — no JSON blocks, just field names and values.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Setup
Install library |
pip install robotframework-okw-api-rest
|
Import in Settings |
Library okw_api_rest.library.OkwApiRestLibrary WITH NAME RESTAPI
|
Minimum Python version |
Python >= 3.10 |
Minimum RF version |
robotframework >= 6.0 |
YAML locator file required: locators/ServiceName.yaml with __self__.base_url and __self__.content_type. See README for full YAML examples.
|
Start / Stop
RESTStart service |
Start REST service (load YAML) |
RESTStart service env |
Start with environment file |
RESTStop |
Stop REST service |
YAML config separates URLs and credentials from test code. Environment files are searched in: ~/.okw/env/ → $OKW_ENV_DIR → locators/ → OS env vars.
Scope
RESTSelectEndpoint /path |
Select endpoint (resets body/headers) |
RESTSetContext path |
Navigate into nested JSON |
RESTSetContext customer.address |
Deeper nesting via dot notation |
RESTSetContext items[0] |
Select array element |
RESTSelectEndpoint resets body, headers, and context. Each RESTSetContext replaces the previous one (flat, no stack).
Input
RESTSetValue field value |
Set body field |
RESTSetValue ?param value |
Set query parameter (? prefix) |
RESTSetHeader name value |
Set request header |
? prefix sends field as URL query parameter instead of body field. Query parameters are not affected by RESTSetContext. Password fields are masked (*) in logs.
Action
RESTSendRequest GET |
Send GET request |
RESTSendRequest POST |
Send POST request |
RESTSendRequest PUT |
Send PUT request |
RESTSendRequest PATCH |
Send PATCH request |
RESTSendRequest DELETE |
Send DELETE request |
Request and response bodies are logged as formatted JSON. After sending, all RESTVerify and RESTMemorize keywords operate on this response.
|
|
Verify
RESTVerifyStatus 200 |
Verify HTTP status code |
RESTVerifyValue field expected |
Verify field value (exact match) |
RESTVerifyValueWCM field text |
Wildcard match (* ?) |
RESTVerifyValueREGX field ^[a-f]+$ |
Regex match |
RESTVerifyHeader name expected |
Verify response header |
RESTVerifyResponseTime 500 |
Response time < 500ms |
Dot notation for nested fields: data.user.name. With active context, fields resolve relative to context path. ResponseTime checks elapsed time, not timeout.
Memorize
RESTMemorizeValue field NAME |
Store response field value |
RESTMemorizeBody NAME |
Store entire response body |
$MEM{NAME} |
Use stored value in next request |
Use $MEM{NAME} in any keyword: RESTSetValue, RESTSetHeader, RESTSelectEndpoint. Missing keys cause an immediate error. Values persist across endpoints until RESTStop.
Tokens
$IGNORE |
Skip keyword (no-op) |
$EMPTY |
Empty string |
$MEM{KEY} |
Stored value from RESTMemorizeValue |
RESTSetValue email $IGNORE → field not sent. RESTSetValue email $EMPTY → field sent as "". RESTSetHeader x-auth-token $MEM{TOKEN} → inserts stored token value.
Phase Model
Start |
RESTStart |
Scope |
RESTSelectEndpoint |
Input |
RESTSetValue / RESTSetContext / RESTSetHeader |
Action |
RESTSendRequest |
Verify |
RESTVerifyValue / RESTVerifyStatus |
Memorize |
RESTMemorizeValue |
Stop |
RESTStop |
Every REST test follows this sequence. Same pattern as OKW GUI keywords: StartApp → SelectWindow → SetValue → ClickOn → VerifyValue → StopApp.
vs. Playwright (Code-Based)
data: { title: 'Test' } |
RESTSetValue title Test |
expect(response.status()).toBe(201) |
RESTVerifyStatus 201 |
const body = await response.json() |
Not needed — automatic |
expect(body.title).toBe('Test') |
RESTVerifyValue title Test |
if (email) payload.email = email |
RESTSetValue email $IGNORE |
{ nested: { key: 'val' } } |
RESTSetContext nested + RESTSetValue key val |
No JSON syntax, no async/await, no variable assignments. Field name + value — readable by testers, BAs, and AI. Same keyword model for GUI and API testing.
|