Skip to content

Session Actions

This page defines all of the built in session scoped actions.

$

Selects a single element using the provided CSS selector and scopes all nested actions to that element. Any nested evaluators or actions will operate relative to this selection.

  • selector: The CSS selector. Can be a static string or expression.
$ "#search-input" {
type "Tadpole HQ"
mouse.press "Enter"
}

Selects all elements matching the provided CSS selector. This creates a collection context.

  • selector: The CSS selector. Can be a static string or expression.
$$ ".result-card" {
extract "results" {
title { text }
link { attr "href" }
}
}

Applies a new identity for the provided platform. It will always use Chrome/Chromium. It will also override any high entropy user agent metadata headers.

  • platform: The platform to generate the identity for. Options are windows, mac and linux.
  • limit: The number of recent browser releases to consider. It is better to keep this value lower if stealth is required. Defaults to 3.
apply_identity windows // This will apply a Windows UA using a recent browser release

Clicks on the active element. It uses a natural movement (bezier curve) to hover the mouse over the element and optionally delay before clicking the target.

  • delay: The delay between hovering and clicking the target. Can be a static number or expression. Defaults to 0.
  • mouseclick.*: Prefixed options. See mouse.click options
  • hover.*: Prefixed options. See hover options
$ "#submit-button" {
click delay="=gauss(0.5, 0.25)"
}

Executes the children nodes. Can be conditional by providing if and can be repeated by providing n.

  • if: The execution condition. Can be an expression. Defaults to undefined.
  • n: The number of times to execute the body. Defaults to 1.
do if="=env('CHECK_SOMETHING')" {
...
}
do n=3 {
...
}

Extracts data from the current element context into a structured record (JSON). Each child node of extract defines a key in the resulting object and the evaluator(s) used to fetch its value.

  • path: The target key or dot-delimited path (e.g., user.profile) where the record will be stored in the global state. Supports static strings or expressions.

The name of each child node becomes a key in the output record. The children of these nodes are evaluators because we need to produce a value.

$$ ".product-card" {
extract "products" {
title { text }
price {
$ ".amount"
text
}
details {
attr "data-info"
}
}
}
// Output: {"products": [{"title": "...", "price": "...", "details": "..."}, ...]}
$ ".header" {
extract "metadata.page" {
title { text }
url { attr "href" }
}
}
// Output {"metadata": {"page": {"title": "...", "url": "..."}}}

Iterates over a collection of elements selected by a parent $$ block. This action is required when you need to perform individual interactions (like click or hover) on every item in a list.

$$ ".result-item" {
for_each {
$ "button.expand" { click }
}
}

Uses a combination of an ease-out function to scroll and a bezier curve to move the mouse over the active element.

Navigates the current browser tab to a specified URL.

  • url: The url to navigate to. Can be a static string or expression.
  • wait_until: The event to wait for after navigating (load or domcontentloaded). Defaults to load.
  • timeout: The timeout (in ms) for the wait_until event to fire. Defaults to 5000. Can be a static number or expression.

Executes the actions in the do and next child nodes while the evaluators in the if child node return a truthy value.

The actions in do are executed before the check and the actions in next are executed only if the check returns a truthy value.

  • some: If the active node is a collection, return true if at least one element meets the predicate.
loop {
do {
extract "data[]" {
...
}
}
while {
$ "#pagination-next"; prop disabled; as_boolean; not
}
next {
$ "#pagination-next" { click }
wait_until
}
}

Allows the children nodes to throw an exception. This is useful when there are instances when some event may or may not fire, i.e a dialog appearing to signup for a newsletter.

maybe {
wait_for "#dialog"
$ "#dialog .close-button" { click }
}

Executes the action in the do node if the evaluators in the if node evaluate to true.

once {
if { $ "#username" }
do {
$ "#username" { type "=env('USERNAME')" }
$ "#password" { type "=env('PASSWORD')" }
$ "button[type='submit']" { click }
}
}

Executes the children node in parallel.

parallel {
screenshot loading
wait_for "#form"
wait_for ".container"
}

Executes only one of the children nodes. This action supports weights.

  • weights: A comma separated list of integers representing the weight of its corresponding child. Defaults to undefined.
    • If the length of weights is less than the children nodes, the weight defaults to 1.
    • They do not need to add up to 100 or 1.0, the relative probability is automatically calculated.
// Select windows 95% of the time, linux 5% of the time
random weights="95,5" {
apply_identity windows
apply_identity linux
}

Takes a screenshot and saves it to the provided path.

  • path: The path to save to. Can be a static string or expression.
  • format: The format to save the screenshot in. Options are jpeg, png and webp. Default to png.
  • quality: If using jpeg, the image quality between 0 and 100. Defaults to 100.
  • clip.: Prefixed options to clip the screenshot. Clipping is enabled if any of these values are passed.
    • x: The x offset. Defaults to 0.
    • y: The y offset. Defaults to 0.
    • width: The width. Defaults to 1280.
    • height: The height. Defaults to 720.
    • scale: The scale factor. Defaults to 1.
screenshot "path/to/file"
screenshot "path/to/file" format=jpeg
screenshot "path/to/file" clip.x=100 clip.y=100 clip.width=100 clip.height=100

Overrides the reported device memory in the user agent metadata headers.

  • memory: The device memory report (in GB)
set_device_memory 8

Overrides the reported hardware concurrency.

  • concurrency: The hardware concurrency to report.
set_hardware_concurrency 4

Overrides the viewport metrics.

  • width: The viewport width.
  • height: The viewport height.
  • deviceScaleFactor: The scale factor. Defaults to 1.
  • mobile: Whether to emulate a mobile device. Defaults to false.
  • screenWidth: The screen width. Defaults to width (emulating full screen).
  • screenHeight: The screen height. Defaults to height (emulating full screen).
set_viewport 1920 1200 // maximized
set_viewport 1920 1200 screenHeight=1009 // accounts for top bar

Overrides the reported WebGL vendor and renderer.

  • vendor: The WebGL vendor to report.
  • renderer: The WebGL renderer to report.
set_webgl_vendor "Google Inc. (Intel)" "ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0)"
set_webgl_vendor "Apple Inc." "Apple M1"

Clicks on the active element and types in the provided text.

It uses hover internally so it uses the same combination of an ease-out function to scroll and a bezier curve to move the mouse.

  • text: The text to type. Can be a static string or expression.
  • delay: The delay between clicking the target and typing. Can be a static number or expression.
  • click.*: Prefixed options. See click options
  • keyboardtype.*: Prefixed options. See keyboard.type options

Waits for the children evaluators to return true. This is useful to wait for the addition/deletion of elements/attributes as internally it uses Mutationobserver.

  • timeout: The maximum amount of time to wait for the evaluators to return true (in ms). Defaults to 5000.
wait_for { $ "div[role='dialog']" }
$ "div[role='dialog'] button" { click }
wait_for { $ "div[role='dialog']"; not }

Waits until the specified browser event fires.

  • event: The event to wait for. Defaults to load.
    • load
    • domcontentloaded
    • networkIdle
    • networkAlmostIdle
  • timeout: The maximum amount of time to wait for the provided event to fire (in ms). Defaults to 5000.
$ "#some-link" { click }
wait_until