Action Object
Every entry inside a page's actions array is an action object. It describes one interaction the engine should perform — typing into a field, clicking a button, selecting a dropdown option, solving a captcha, and so on. All action objects share a common set of fields described on this page. The specific action types (type, click, select, etc.) are covered in the Actions Reference.
Fields Reference
| Field | Type | Description |
|---|---|---|
action / type | string | The action name — what to do. Required. |
selector | string | string[] | The target element. CSS selector, XPath, or text selector. Array = fallback chain. |
value | string | The value to type, select, or use. Supports {{tokens}}. |
optional | boolean | When true, skip silently if element not found. |
delay | number | Milliseconds — wait duration, keystroke timing, settle time. |
include_frames | boolean | Search inside iframes. Default true. |
max_frames | number | Max child frames to search. Default 8, cap 24. |
Action Name — action or type
The action field (or type — both work interchangeably) tells the engine what kind of interaction to perform. It is the only strictly required field in every action object. Common values include:
// Type text into an input field
{ "type": "type", "selector": "#email", "value": "{{EMAIL}}" }
97
{ "type": "click", "selector": ".next-btn" }
169
{ "type": "select", "selector": "#state", "value": "{{STATE}}" }
271
{ "type": "wait", "delay": 2000 }
334
{ "type": "captcha" }
390
{ "type": "popup_close", "optional": true }
463
{ "type": "sheet_status", "value": "lead" }You can use either "action" or "type" as the field name — the engine treats them identically. Most scripts use type by convention.
Selector — Targeting Elements
The selector field tells the engine which element on the page to interact with. Ghost RPA supports three selector formats: CSS selectors, XPath expressions, and text selectors.
CSS Selectors
The most common format. Use the element's id, class, name attribute, or any valid CSS selector. To find a selector, right-click the element in Chrome → Inspect → look at the highlighted HTML.
// By ID (fastest and most reliable)
{ "type": "type", "selector": "#email", "value": "{{EMAIL}}" }
101
{ "type": "click", "selector": ".submit-button" }
169
{ "type": "type", "selector": "input[name='phone']", "value": "{{PHONE}}" }
267
{ "type": "click", "selector": "button[data-step='next']" }XPath Selectors
Prefix with xpath= to use an XPath expression. XPath is powerful for matching elements by their visible text — especially buttons and links where the text is the only unique identifier.
// Button by its visible text
{ "type": "click", "selector": "xpath=//button[contains(normalize-space(),'Next')]" }
117
{ "type": "type", "selector": "xpath=//*[@id='firstName']", "value": "{{FIRST_NAME}}" }
233
{ "type": "click", "selector": "xpath=//div[normalize-space()='I Agree']" }
342
{ "type": "type", "selector": "xpath=//form[@id='contact']//input[@name='email']", "value": "{{EMAIL}}" }Text Selectors
Prefix with text= to find an element by its exact visible text. This is the simplest option for buttons and links with unique text.
// Click a button with exact text
{ "type": "click", "selector": "text=Submit Application" }
94
{ "type": "click", "selector": "text=Skip this step" }Fallback Selector Array
When selector is an array, the engine tries each selector in order and uses the first one that finds a visible element. This is extremely useful when websites change their DOM between visits, A/B test different layouts, or use dynamic IDs.
// Try CSS first, fall back to XPath
{
"type": "type",
"selector": ["#email", "xpath=//*[@id='email']", "input[name='email']"],
"value": "{{EMAIL}}"
}
158
{
"type": "click",
"selector": [
"button.ef-nav__btn--next",
"xpath=//button[contains(normalize-space(),'Next')]",
"text=Continue"
]
}Using a fallback array makes your script resilient. If the site changes one selector, the script keeps working because the fallback still matches.
Value — Static Text and Tokens
The value field holds whatever data the action needs — text to type, an option to select, or a URL to navigate to. Values can be static text, spreadsheet tokens, or a mix of both.
// Static text
{ "type": "type", "selector": "#company", "value": "Acme Corp" }
81
{ "type": "type", "selector": "#email", "value": "{{EMAIL}}" }
208
{ "type": "type", "selector": "#full-name", "value": "{{FIRST_NAME}} {{LAST_NAME}}" }
339
{ "type": "select", "selector": "#state", "value": "{{STATE}}" }
435
{ "type": "navigate", "value": "https://example.com/apply?zip={{ZIP}}" }Tokens use double curly braces: {{COLUMN_NAME}}. The column name matches your spreadsheet header and is case-insensitive — {{email}}, {{EMAIL}}, and {{Email}} all pull from the same column. See Data Tokens for the full list of built-in generators and special tokens.
Optional Actions
Set optional: true on any action that targets an element which may or may not appear. When the element isn't found, the engine skips the action silently and moves to the next one — no error, no retry, no failed run.
// Cookie banner — appears on first visit only
{
"type": "click",
"selector": "#cookie-accept",
"optional": true
}
122
{
"type": "popup_close",
"selector": ".modal-overlay .close-btn",
"optional": true
}
243
{
"type": "type",
"selector": "#middle-name",
"value": "{{MIDDLE_NAME}}",
"optional": true
}
395
{
"type": "click",
"selector": "button.ef-nav__btn--next",
"optional": true
}Without optional: true, the engine waits for the element and retries when it's not found. If the element genuinely doesn't exist on that visit, the action times out and the run fails. Use optional liberally for anything that might not be there.
Delay
The delay field specifies a time in milliseconds. Its meaning depends on the action type:
// wait action — pause for 2 seconds between steps
{ "type": "wait", "delay": 2000 }
86
{ "type": "wait", "delay": 300 }
182
{ "type": "press", "key": "Tab", "delay": 100 }
273
{ "type": "popup_close", "selector": ".modal .close", "delay": 500 }Adding short wait actions (200–500ms) between field fills helps with sites that run validation on blur or debounce input. For pages that load slowly, use auto_wait instead of a fixed delay.
Frame Searching
By default, the engine searches both the main page and all child iframes for the target element. This handles common cases like captcha iframes and embedded forms automatically.
// Default behavior — searches main page + up to 8 iframes
{ "type": "click", "selector": "#submit" }
103
{
"type": "click",
"selector": "#submit",
"include_frames": false
}
226
{
"type": "type",
"selector": "#card-number",
"value": "{{CARD}}",
"max_frames": 16
}Set include_frames: false when an iframe contains an element with the same selector as the one you want on the main page. Increase max_frames (up to 24) when the target element is inside a deeply nested iframe chain.
How Actions Execute
Understanding the action lifecycle helps you write reliable scripts. When the engine runs an action, it follows this sequence:
- Wait for element — the engine automatically waits for the selector to appear on the page. You don't need to add a separate wait action before every interaction.
- Execute — once the element is found and visible, the engine performs the interaction (types text, clicks, selects an option, etc.).
- Retry on failure — if the interaction fails (element moved, page updated), the engine retries within the timeout window.
- Handle not-found — if the element is never found:
- With
optional: true→ skip silently, move to the next action. - Without
optional→ the step fails and the run reports an error.
- With
- Next action — after the action completes (or is skipped), the engine moves to the next action in the array.
- Back to detection — after all actions in the current page complete, the engine returns to page detection and scans for the next matching page.
Complete Examples
Simple Form Fill
A typical contact form page — type into fields, then click submit:
"actions": [
{
"type": "type",
"selector": "#firstName",
"value": "{{FIRST_NAME}}"
},
{ "type": "wait", "delay": 300 },
{
"type": "type",
"selector": "#lastName",
"value": "{{LAST_NAME}}"
},
{ "type": "wait", "delay": 300 },
{
"type": "type",
"selector": "#email",
"value": "{{EMAIL}}"
},
{ "type": "wait", "delay": 300 },
{
"type": "type",
"selector": ["#phone", "input[name='phone']"],
"value": "{{PHONE}}"
},
{ "type": "wait", "delay": 500 },
{
"type": "click",
"selector": [
"xpath=//button[contains(normalize-space(),'Next')]",
"button.submit-btn"
]
}
]Dropdown, Checkbox, and Captcha
A step with a dropdown selection, a terms checkbox, a captcha, and a submit button:
"actions": [
{
"type": "select",
"selector": "#state",
"value": "{{STATE}}"
},
{ "type": "wait", "delay": 300 },
{
"type": "type",
"selector": "#zip",
"value": "{{ZIP}}"
},
{
"type": "checkbox",
"selector": "#agree-terms"
},
{
"type": "captcha"
},
{
"type": "click",
"selector": "xpath=//button[normalize-space()='Submit']"
},
{
"type": "sheet_status",
"value": "lead"
}
]Optional Popup Handling
A landing page where a cookie banner and a promo popup may or may not appear before the main form:
"actions": [
{
"type": "popup_close",
"selector": "#cookie-banner .accept",
"optional": true
},
{
"type": "click",
"selector": ".promo-modal .close-btn",
"optional": true
},
{
"type": "type",
"selector": "#zipcode",
"value": "{{ZIP}}"
},
{
"type": "click",
"selector": "#get-quote-btn"
}
]Mixed Selectors with Waits
A step that uses CSS, XPath, and fallback arrays together — a real pattern from a multi-step loan form:
"actions": [
{
"type": "type",
"selector": ["xpath=//*[@id='email']", "#email"],
"value": "{{EMAIL}}"
},
{ "type": "wait", "delay": 300 },
{
"type": "type",
"selector": ["xpath=//*[@id='cellPhone']", "#cellPhone"],
"value": "{{PHONE}}"
},
{ "type": "wait", "delay": 1000 },
{
"type": "click",
"selector": [
"xpath=//button[contains(normalize-space(),'Next')]",
"button.ef-nav__btn--next",
"text=Continue"
]
}
]