Data Caching
You can save elements or values during a task and reuse them in later actions.
Element Cache ($key)
Find an element once and save it with "save": "name". Use $name to reference it later instead of repeating the selector.
Find and save:
[
{ "find": ".submit-button", "options": { "save": "submitBtn" } }
]
Use it:
[
{ "click": "$submitBtn" }
]
Saved elements only last for the current page. If you navigate to a new page, the saved element is gone.
Data Cache (${key})
Read a value from the page and save it with "save": "name". Use ${name} to insert it into any text field later.
Read and save:
[
{ "getText": ".username", "options": { "save": "userName" } }
]
Insert into a later action:
[
{ "fill": ["input#greeting", "Hello ${userName}!"] }
]
Collect multiple values into a list with push:
[
{ "getText": ".item-name", "options": { "push": "itemNames" } }
]
Each time this runs, the value is added to the itemNames list.
Saved values carry over between tabs and between requests in the same session. They are cleared at the start of each new task.
getSavedData
Read saved values back into the task result.
Value: list of names to read
[
{ "getSavedData": ["userName", "itemNames"] }
]
Returns:
{
"userName": "John Doe",
"itemNames": ["Item 1", "Item 2", "Item 3"]
}
clearSavedData
Delete all saved values.
Value: true
[
{ "clearSavedData": true }
]
Escape $
If you need a real $ in a text value, write $$:
[
{ "fill": ["input.price", "$$19.99"] }
]
This types $19.99.
Summary
| Element Cache | Data Cache | |
|---|---|---|
| How to reference | $name | ${name} |
| What it stores | A page element | A text or number value |
| How to save | "save" on find / waitForElement | "save" on getText / getAttribute / etc. |
| How long it lasts | Until you navigate to a new page | Until the task ends (or session ends) |
| Can collect a list | No | Yes — use "push" instead of "save" |
Example: Extract and Reuse Data
[
{ "openNewTab": "https://example.com/product/123" },
{ "getText": "h1.product-name", "options": { "save": "productName" } },
{ "getText": ".price", "options": { "save": "productPrice" } },
{ "getAttribute": ["a.brand-link", "href"], "options": { "save": "brandUrl" } },
{ "open": "${brandUrl}" },
{ "waitForElement": ".brand-page" },
{ "fill": ["input.search", "${productName}"] },
{ "click": "#search-btn" },
{ "getSavedData": ["productName", "productPrice", "brandUrl"] }
]
Example: Collect Multiple Values in a Loop
[
{ "openNewTab": "https://example.com/products" },
{ "waitForElement": ".product" },
{
"loop": {
"each": ".product",
"do": [
{ "getText": "$this .name", "options": { "push": "names" } },
{ "getText": "$this .price", "options": { "push": "prices" } }
]
}
},
{ "getSavedData": ["names", "prices"] }
]