Define & Export
Define
Create named aliases for selectors within a Within block:
Within the Browser (plugin: playwright-python, type: browser) Define submit-button (id: 'submit', class: 'primary') Define email-input (label: 'Email')
click submit-button type "user@example.com" into email-inputAliases are resolved at compile time. They can only be used in unquoted pattern slots and shadow literal tokens.
Scoping Rules
Defineis only valid inside aWithinblock- Aliases are scoped to their enclosing
Withinblock - Aliases cannot be exported (they are context-specific)
- Reserved words (
Script,Within,Define,Export) cannot be used as alias names - If an alias name collides with an existing name in the same scope, it is a compile error
Capture
Capture values from responses into variables:
Within the API (plugin: python-requests, type: api, base: 'http://localhost:8080') POST "/users" body '{"name": "alice"}' Capture "$.id" as userIdVariables created via Capture can be interpolated in later statements using {varname} syntax:
GET "/users/{userId}"Export
Export captured variables for use in sibling and subsequent Within blocks:
Within the API (plugin: python-requests, type: api, base: 'http://localhost:8080') POST "/users" body '{"name": "alice", "email": "alice@test.com"}' Capture "$.id" as userId Export userId
Within the Browser (plugin: playwright-python, type: browser, url: 'http://localhost:8080') go to "/users/{userId}" see any user-profileExport Rules
Exportonly works on variables (not aliases)Exportis only valid directly inside aWithinblock (not inside pattern blocks)Exportmust appear after the variable is captured, within the sameWithinblock- Exporting an undefined variable is a compile error
- Exporting the same name from multiple blocks is a compile error
- If a variable and alias have the same name in overlapping scope, it is a compile error