Actions
Basic actions
Actions are statements that perform operations. They are matched against patterns defined in plugins. Each action consists of tokens (identifiers, strings, or numbers) that match a plugin-defined pattern.
go to "https://example.com"click buttontype "hello" into search-inputActions can only appear inside Within blocks, where they are matched against the patterns defined for that block’s type.
Pattern matching
Actions are matched against patterns defined in plugins. The plugin determines which actions are valid in each context. Patterns define the syntax using literal words and typed slots.
For example, in a browser context (from the playwright-python plugin):
go to <url:quoted>- navigate to URLsee url <url:quoted>- assert current URL matches exactlysee url contains <url:quoted>- assert current URL contains stringclick <target:unquoted>- click an elementtype <text:quoted> into <target:unquoted>- type into an inputpress <key:unquoted>- press a keyboard key (e.g.,Enter,Tab,Escape)see <q:a|an|any|no> <target:unquoted>- assert element visibilitywait for <target:unquoted>- wait for an element to appear
In an api context (from the python-requests plugin):
GET <path:quoted>- make a GET requestPOST <path:quoted> body <body:quoted>- make a POST request with bodyexpect status <code:unquoted>- assert response status codeexpect json <path:quoted> == <value:quoted>- assert JSON value
Slots
Patterns have slots (placeholders) that capture values:
type "hello" into search-input ^^^^^^^ ^^^^^^^^^^^^ text slot target slot (quoted) (unquoted)Slots can be:
- quoted - must be a string literal (single or double quotes)
- unquoted - must be an identifier or hyphenated identifier (like
submit-button) - union - one of several literal keywords
Quoted slots
Quoted slots capture string literals. They are written as <name:quoted> in patterns.
go to "/login"type "user@example.com" into email-inputPOST "/users" body '{"name": "alice"}'Quoted strings support variable interpolation with {var}:
GET "/users/{user_id}"Unquoted slots
Unquoted slots capture identifiers or hyphenated identifiers. They are written as <name:unquoted> in patterns.
click buttonclick submit-buttontype "hello" into email-inputUnquoted slots can reference aliases defined with Define:
Define submit-button (id: 'submit', class: 'primary')click submit-buttonUnion slots
Union slots accept one of several literal keywords. They are written as <name:keyword1|keyword2|...> in patterns.
see a div (class: 'welcome')see an input (id: 'email')see any buttonsee no span (class: 'error')In the see pattern, the quantifier slot accepts a, an, any, or no:
aoran- exactly one element must matchany- at least one element must matchno- zero elements must match
Action modifiers
Actions can have modifiers that provide additional parameters. Two syntaxes are supported:
Parentheses syntax
click button (id: 'submit', timeout: '5s')see a div (class: 'welcome', text: 'Hello')With syntax
click button with id: 'submit', timeout: '5s'see a div with class: 'welcome', text: 'Hello'Both syntaxes are equivalent. Modifier keys and their valid types are defined by the plugin pattern.
Common modifiers for browser actions:
timeout- wait timeout for the actionid,class,testid,label- element selectorstext- expected text content (see warning below)state- assertion state forsee(attached,hidden) or wait state forwait for(visible,hidden,attached,detached)
Action blocks
Some actions can have nested blocks with child statements. The action block is indented under the action.
POST "/orders" body '{"items": [...]}' expect status 201 capture "$.id" as order_idAction blocks can contain:
- Child action statements (like
expect status 201) - Capture statements (like
capture "$.id" as order_id)
The pattern’s returns field in the plugin determines what type of block is opened. For example, the expect failure pattern returns a failure_block where errors are expected:
expect failure (error: 'TimeoutError') click missing-buttonNumbers in actions
Action tokens can include numbers for patterns that need them:
expect status 200wait 5 secondsNumbers are written as bare digits without quotes.
Form element interactions
Checkboxes and radio buttons
Use click to toggle checkboxes and select radio buttons. Vanya relies on Playwright’s native click behavior:
# Toggle a checkboxclick input (testid: 'agree-checkbox')click input (role: 'checkbox')
# Select a radio buttonclick input (testid: 'option-a')click input (role: 'radio', name: 'Option A')Clicking a checkbox toggles its checked state. Clicking a radio button selects it and deselects other radios in the same group. There is no separate check or toggle verb in Vanya - click is the canonical way to interact with these elements.
Verifying checkbox state
To verify a checkbox is checked or unchecked:
# Verify checkbox is visible and can be clickedsee a input (role: 'checkbox', name: 'Agree')
# After clicking, verify the todo is marked completeclick input (role: 'checkbox')see a li (class: 'todo-item completed')