Skip to content

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-input

Aliases are resolved at compile time. They can only be used in unquoted pattern slots and shadow literal tokens.

Scoping Rules

  • Define is only valid inside a Within block
  • Aliases are scoped to their enclosing Within block
  • 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 userId

Variables 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-profile

Export Rules

  • Export only works on variables (not aliases)
  • Export is only valid directly inside a Within block (not inside pattern blocks)
  • Export must appear after the variable is captured, within the same Within block
  • 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