Page Object

The pages array is the core of every script. Each entry describes one screen or step in the web flow — a landing page, a form step, a qualification question, a thank-you confirmation. The engine reads every page definition and continuously checks which one matches the current browser state. When a match is found, it runs that page's actions.

Pages are not followed in order. The engine matches whichever page fits right now, regardless of its position in the array. This means your script automatically handles redirects, popups, branching paths, and pages that load in an unexpected sequence — without any extra logic on your part.

Page Fields

Every page object has three fields:

FieldTypeDescription
namestringA human-readable label for this page. Shown in logs and debugging output.
detectobjectRules that tell the engine when this page is active. See Detection Rules.
actionsarrayAn ordered list of actions to execute when this page is detected. See Action Object.

The name Field

The name is a label you choose — it has no effect on how the script runs, but it appears in every log line related to that page. A good name tells you exactly where the automation is at a glance. Use a descriptive format like "Step N - What This Page Does".

JSON
// Good — descriptive and easy to scan in logs
"name": "Step 1 - Zip Code"
"name": "Step 2 - Contact Info"
"name": "Step 3 - Coverage Selection"
"name": "Thank You Page"
"name": "Popup - Cookie Banner"

203
"name": "Page 1"
"name": "Form"
"name": "Next"

When you see an error in the logs, the name tells you which page it happened on. If your names are vague, you will waste time figuring out which step failed.

The detect Field

The detect object contains the rules the engine uses to decide whether this page is currently active in the browser. You can match by URL, by visible text on the page, by CSS selectors or XPaths, or any combination of these.

JSON
{
  "name": "Contact Form",
  "detect": {
    "url_contains": "/contact",
    "text": "Enter your contact details",
    "selector": "#first-name",
    "mode": "all"
  },
  "actions": [...]
}

With mode: "all" (the default), every rule must match for the page to be detected. This prevents false matches on pages that share similar URLs or text. For the full list of detection options, see Detection Rules.

The actions Field

The actions array lists everything the engine should do on this page, in order. Each entry is an action object with at least a type field (what to do) and usually a selector (which element to interact with).

JSON
{
  "name": "Step 2 - Email",
  "detect": {
    "url_contains": "example.com",
    "text": "What Is Your Email Address?"
  },
  "actions": [
    {
      "type": "type",
      "selector": ["xpath=//*[@id='email']", "#email"],
      "value": "{{EMAIL}}"
    },
    { "type": "wait", "delay": 300 },
    {
      "type": "click",
      "selector": "xpath=//button[contains(normalize-space(),'Next')]"
    }
  ]
}

Actions run top to bottom. Each action waits for its target element to appear before executing. If an element isn't found within the timeout, the action retries automatically. For the full list of action parameters, see Action Object.

How Page Matching Works

When a run starts, the engine opens the browser, navigates to the script's offerURL, and enters a detection loop:

  1. The engine checks every page definition in your script against the current browser state.
  2. When a page's detect rules match, its actions execute in order.
  3. After all actions complete, the engine goes back to step 1 — scanning all pages again.
  4. This loop continues until a sheet_status or exit action runs, which ends the current run.

Because the engine re-scans after every page, your script handles multi-step forms naturally. When clicking "Next" loads a new page, the engine detects the new page and runs its actions — no matter how many steps the form has.

This also means the order of pages in your pages array doesn't matter for execution. The engine always matches based on what's currently in the browser. However, keeping them in logical order makes your script easier to read and maintain.

Complete Example

Here is a realistic pages array for a multi-step registration form with four steps. Notice how each page has specific detection rules and the final page writes the result back to the spreadsheet.

JSON
"pages": [
  {
    "name": "Step 1 - Zip Code",
    "detect": {
      "url_contains": "/get-quote",
      "selector": "#zipcode",
      "text": "Enter your zip code",
      "mode": "all"
    },
    "actions": [
      {
        "type": "type",
        "selector": "#zipcode",
        "value": "{{ZIP}}"
      },
      {
        "type": "click",
        "selector": "xpath=//button[contains(normalize-space(),'Get Quote')]"
      }
    ]
  },
  {
    "name": "Step 2 - Contact Info",
    "detect": {
      "url_contains": "/step-2",
      "selector": ["#first-name", "#last-name", "#email"],
      "mode": "all"
    },
    "actions": [
      { "type": "type", "selector": "#first-name", "value": "{{FIRST_NAME}}" },
      { "type": "wait", "delay": 200 },
      { "type": "type", "selector": "#last-name", "value": "{{LAST_NAME}}" },
      { "type": "wait", "delay": 200 },
      { "type": "type", "selector": "#email", "value": "{{EMAIL}}" },
      { "type": "wait", "delay": 200 },
      { "type": "type", "selector": "#phone", "value": "{{PHONE}}" },
      { "type": "click", "selector": ".next-btn" }
    ]
  },
  {
    "name": "Step 3 - Homeowner Question",
    "detect": {
      "url_contains": "/step-3",
      "text": "Are you a homeowner?",
      "mode": "all"
    },
    "actions": [
      {
        "type": "click_random",
        "selectors": [
          "xpath=//button[normalize-space()='Yes']",
          "xpath=//button[normalize-space()='No']"
        ]
      }
    ]
  },
  {
    "name": "Thank You Page",
    "detect": {
      "text": "Thank you for your submission",
      "url_contains": "/thank-you"
    },
    "actions": [
      { "type": "sheet_status", "value": "lead" }
    ]
  }
]

Tips

  • Be specific with detection. Two pages on the same site can share a URL — always add a text or selector rule alongside url_contains to avoid false matches.
  • Add a page for every screen. If the site can show a popup, a loading screen, a "welcome back" page, or an error message, define a page for it. The engine only runs actions on pages it recognises.
  • End every flow with sheet_status. The final page (usually a thank-you or confirmation) should write the result back to the spreadsheet. Without this, the engine doesn't know the run succeeded.
  • Use optional for unreliable elements. If a popup or banner only appears sometimes, add it as an action with "optional": true so the script doesn't fail when it's not there.
  • Keep pages in logical order. The engine doesn't care about order, but you will — when debugging a 20-step script, having pages in flow order makes it much easier to find the right one.