Retrieve value(s)
Extract information from the page open in a browser session. Use JSON extraction rules to select elements and return named values, or use AI extraction with a query and JSON Schema.
The Advanced selectors option accepts the same locator strings as other web actions. Existing CSS and XPath rules keep their configuration format, including job templates that show the older CSS Selector(s) label.
When to use this action
| What you need | Extraction type | Configuration |
|---|---|---|
| Text, attributes, or current form values | Advanced selectors | A locator string for each value. |
| Lists of records or rows from a table | Advanced selectors | List rules, nested fields, or a table output. |
| Information described in natural language | AI Extraction | A query and JSON Schema describing the result. |
Both extraction types return named values that you can use in downstream Wrk Actions.
Application
Web - Vision
Inputs (what you have)
| Name | Description | Required? |
|---|---|---|
| Browser session ID | Session returned by Open web session. | Yes |
| Extraction type | Advanced selectors or AI Extraction. Older configurations may show CSS Selector(s) for selector extraction. | Yes |
| Data extraction rules | JSON object defining the values to extract. See Extraction rule basics. | For selector extraction |
| Query | Natural-language instructions for AI extraction. If omitted, the action asks the AI to follow the supplied schema. | No |
| AI data extraction rules | JSON Schema describing the object the AI should return. See AI extraction. | For AI extraction |
Inputs can use fixed values or values from the Data Library.
Outputs (what you get)
| Name | Description |
|---|---|
| Extracted content | The extracted object serialized as JSON text, such as {"title":"The Wrk Blog"}. |
| Unsuccessful message | Error details when available. |
| Unsuccessful screenshot | A debugging screenshot when available for a browser error. |
| Custom Outputs | Named values configured from the extracted content. |
For example, if Extracted content contains {"title":"The Wrk Blog"}, create a Custom Output named title using the path $.title. See Custom Outputs for choosing a source output and reading nested values.
Outcomes
| Name | Description |
|---|---|
| Success | An extracted object was returned. Its individual fields may still contain missing values. |
| No result | Extraction returned no object or an empty object, for example when the rules are {}. |
| Impossible to complete | The action could not complete, for example because it could not connect to the browser session. |
A selector that finds no element does not automatically produce No result. For example, {"title":"#missing"} returns {"title":null} as a successful extracted object. Invalid rules and browser-session errors fail the action.
Extraction rule basics
Enter a JSON object in Data extraction rules. Each top-level key becomes a field in the extracted object.
A CSS or advanced locator string reads the trimmed text of the first matching element. Bare XPath strings retain the behavior described under Lists and nested objects. An object rule lets you choose an output format or extract several matches:
| Rule | What it returns |
|---|---|
{"title":"h1"} | Text from the first heading. |
{"link":{"selector":"a","output":"@href"}} | The first link's href attribute. |
{"titles":{"selector":"h2","type":"list"}} | Text from every matching heading, as an array. |
CSS is recognized automatically. To use another locator, change the selector text in the same rule, for example from "#email" to "role=textbox[name='Email']".
Read attributes with "output":"@attribute", such as "@href", "@id", or "@data-price". Relative URLs remain relative. CSS multi-valued attributes such as @class and @rel return arrays. The shorthand "a@href" is not supported.
Rule options
| Field | Accepted value | Behavior |
|---|---|---|
selector | Raw locator string | Required. Identifies elements to read; CSS is recognized automatically. |
output | Output name or nested rule object | Defaults to text. See Output formats. |
type | item or list | Defaults to item, which reads the first match. list reads all current matches. |
match_index | Positive integer | Selects a specific match. Indexes start at 1. |
filter | Object with has_text and/or has_not_text string values | Narrows matches by text within the element. |
A worked example
Suppose the page contains these orders:
<h1>Orders</h1>
<label for="email">Email</label>
<input id="email" value="alex@example.com" />
<article class="order">
<h2>Order A-100</h2>
<a href="/orders/A-100">View order</a>
<span class="status">Paid</span>
</article>
<article class="order">
<h2>Order A-101</h2>
<a href="/orders/A-101">View order</a>
<span class="status">Pending</span>
</article>
Each row below is a complete Data extraction rules input and the JSON returned in Extracted content:
| Use it to | Extraction rules | Output |
|---|---|---|
| Read the page heading | {"title":"h1"} | {"title":"Orders"} |
| Read the current email | {"email":{"selector":"role=textbox[name='Email']","output":"value"}} | {"email":"alex@example.com"} |
| Read the first order URL | {"url":{"selector":"a","output":"@href"}} | {"url":"/orders/A-100"} |
| Read all order names | {"names":{"selector":"h2","type":"list"}} | {"names":["Order A-100","Order A-101"]} |
| Read fields from the first order | {"order":{"selector":"article.order","output":{"name":"h2","status":".status"}}} | {"order":{"name":"Order A-100","status":"Paid"}} |
For the same page, these selectors return the following values when used as string rules:
| Selector | Result |
|---|---|
h1 | Orders |
xpath=//h1 | Orders |
role=heading[name="Orders"] | Orders |
text=/order a-100/i | Order A-100 |
css=article.order >> css=.status | Paid |
article.order >> nth=1 >> css=.status | Pending |
| Selector feature | Example | How it works |
|---|---|---|
| Accessibility role | role=textbox[name='Email'] | Matches the role and accessible name; the input's Email label supplies its name. |
| Text pattern | text=/order a-100/i | Matches text without case sensitivity. |
| Selector chain | article.order >> css=.status | Selects the status within an order. |
| Match index in a locator | h2 >> nth=1 | Selects the second match; nth starts at zero. |
| Placeholder | input[placeholder='Enter email'] | Matches the placeholder attribute. |
| Image alt text | img[alt='Company logo'] | Matches the image's alt attribute. |
| Title | [title='Close'] | Matches the title attribute. |
| Test ID | [data-testid='order-total'] | Matches a test ID attribute. |
Enter locator text just as you would in another web action's Element identifier.
Advanced extraction
Lists and nested objects
Use type: "list" for every match and a nested output object for fields within each item. These examples use the orders page above:
| Use it to | Extraction rules | Output |
|---|---|---|
| Read a field from each order | {"orders":{"selector":"article.order","type":"list","output":{"name":"h2"}}} | {"orders":[{"name":"Order A-100"},{"name":"Order A-101"}]} |
| Read the enclosing link's text and URL | {"link":{"selector":"a","output":{"text":{"selector":"@"},"url":{"selector":"@","output":"@href"}}}} | {"link":{"text":"View order","url":"/orders/A-100"}} |
selector: "@" selects the enclosing matched item inside a nested output.
| XPath form | Example | Scope and result |
|---|---|---|
| Top-level bare XPath | {"urls":"//a/@href"} | Reads matching element, text, or attribute nodes from the document and joins results with spaces. |
| Nested bare XPath | "name":"//h2" inside a nested output | Searches the document of the selected element's frame, then reads the first match's leading text. It can return null when there is no leading text. Use an object rule with output: "text" for complete element text. |
| Explicit relative XPath | {"selector":"xpath=.//a","output":"@href"} inside a nested output | Reads a link relative to the enclosing matched item. |
| Explicit XPath locator | {"title":"xpath=//h1"} | Selects elements and reads the first match's text; text and attribute nodes are not locator targets. |
Filter or select a specific match
Filters narrow matches before match_index is applied. These examples use the headings from the orders page:
| Use it to | Extraction rules | Output |
|---|---|---|
| Read the first match by default | {"name":"h2"} | {"name":"Order A-100"} |
| Read the second match with an option | {"name":{"selector":"h2","match_index":2}} | {"name":"Order A-101"} |
| Read the second match in a locator | {"name":"h2 >> nth=1"} | {"name":"Order A-101"} |
| Include and exclude text | {"name":{"selector":"h2","filter":{"has_text":"A-100","has_not_text":"Cancelled"}}} | {"name":"Order A-100"} |
| Read every match | {"names":{"selector":"h2","type":"list"}} | {"names":["Order A-100","Order A-101"]} |
match_index starts at 1; nth starts at zero. Item rules default to the first match. List rules without an index read all current matches.
Output formats
| Output | Returned value |
|---|---|
text | Legacy text extraction, trimmed at the ends. It can include hidden text. Directly selected scripts, styles, and templates return their text. |
@attribute | HTML attribute value; missing attributes return an empty string. |
html | Outer HTML of the selected element, using the compatible HTML serialization format. |
inner_html | Inner HTML of the selected element. |
inner_text | Rendered text, such as the visible label inside a container. |
text_content | DOM text content without the legacy trimming or whitespace normalization. |
value or input_value | Current value of an input, textarea, or select. |
checked | Boolean checkbox or radio state. |
visible | Boolean visibility of a matched element. |
enabled | Boolean enabled state of a matched element. |
count | Number of matches, including zero. |
table_json | Table or ARIA grid rows as an array of objects keyed by headers. |
table_array | Table or ARIA grid rows as an array of arrays, including the header row. |
For an input initially set to alex@example.com, then edited to updated@example.com:
| Output | Returned value | Use it to |
|---|---|---|
value or input_value | updated@example.com | Read what the user entered. |
@value | alex@example.com | Read the original HTML attribute. |
| Other example | Extraction rules | Returned value |
|---|---|---|
| Checkbox state | {"accepted":{"selector":"#accept-terms","output":"checked"}} | A boolean indicating whether the checkbox is checked. |
| JSON in a script | {"json_ld":{"selector":"script[type='application/ld+json']","output":"text"}} | A string containing the script's JSON. |
Text and HTML output can contain hidden content. There is no clean option; choose text_content for DOM text without legacy normalization.
Tables and ARIA grids
| Table source | Headers | Rows |
|---|---|---|
| HTML table | First nonempty row. | Remaining rows. |
| ARIA grid | Elements with the columnheader role. | Elements with row and gridcell roles; common hidden helper text is excluded. |
For a table selected by #orders, with headers Name and Status and one row containing Alex and Active:
| Extraction rules | Output |
|---|---|
{"rows":{"selector":"#orders","output":"table_json"}} | {"rows":[{"Name":"Alex","Status":"Active"}]} |
{"rows":{"selector":"#orders","output":"table_array"}} | {"rows":[["Name","Status"],["Alex","Active"]]} |
Only rows loaded in the page are returned. Extraction does not scroll or paginate to load the rest of a virtualized grid.
Iframes and shadow DOM
Keep iframe traversal in the locator string. The internal:control=enter-frame transition enters the matched iframe, then the rest of the locator selects within it:
{
"first_name": {
"selector": "iframe[title=\"Form 0\"] >> internal:control=enter-frame >> internal:role=textbox[name=\"First name*\"i]",
"output": "value"
}
}
| Situation | How to handle it |
|---|---|
| Enter an iframe | Use internal:control=enter-frame in the locator string; no separate frame input is needed. |
| Select by role inside the iframe | Use internal:role; the i flag makes the accessible-name match case-insensitive. |
| Enter nested iframes | Repeat the iframe selector and transition for each level. |
| Several iframes match | Narrow the iframe selector or add >> nth=0 before the frame transition. Each iframe step must identify one frame. |
| Choose a final target match | Use match_index; it applies to the target element and does not choose an intermediate iframe. |
| Iframe is missing | The action fails. |
| Iframe exists but the target is missing | The usual missing-value results apply. |
| Extract nested outputs | Rules run within the selected element's frame. |
| Select inside an open shadow root | CSS and other native locators can reach it; XPath cannot. |
| Select inside a closed shadow root | Unavailable. |
| Read a template | Select the template itself to read its stored content; its descendants are not live locator targets. |
Ordinary CSS does not cross iframe boundaries automatically.
Page readiness
| Page state | What to do | Extraction behavior |
|---|---|---|
| Content is still loading | Use Check element or existing web automation steps to check readiness first. | Reads the current matches. |
| A list or grid loads more rows on scroll | Load the rows you need before extracting. | Returns loaded rows without scrolling, pagination, or waiting for a requested count. |
Missing values and compatibility
| Rule or output | Result when missing |
|---|---|
| CSS or advanced locator string | null |
| Top-level bare XPath string | "" |
| Nested bare XPath string | null |
Object rule with type: "item" | {} |
Object rule with type: "list" | [] |
output: "count" | 0 |
@attribute on an existing element | "" |
With CSS/native locator strings or an object rule's text output, an existing element with empty text returns "". A top-level bare XPath string also returns "" when no nodes match, so that shorthand does not distinguish those cases. Nested bare XPath shorthand reads leading text and can return null when a matched element has no leading text; use an object rule for complete element text.
Existing CSS/XPath rule shapes, list and item behavior, text trimming, relative attribute URLs, and table formats remain supported. Browser normalization of malformed markup and parser-specific CSS/XPath expressions can still affect results.
AI extraction
Choose AI Extraction, enter an optional Query, and provide a JSON Schema in AI data extraction rules. For example, use the query "Extract the first three products with their names and prices" with this schema:
{
"type": "object",
"properties": {
"products": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"price": {"type": "string"}
},
"required": ["name", "price"]
}
}
},
"required": ["products"]
}
The JSON Schema describes the result; it does not use selector, output, or the other selector-rule fields. Selector extraction rules do not apply to AI extraction.
Configure extraction in a Wrkflow
- Open a browser session with Open web session, then navigate to the page containing the values.
- Add Retrieve value(s) and map the Browser session ID from that session.
- Choose Advanced selectors and enter a JSON object in Data extraction rules. For AI extraction, choose AI Extraction and provide its query and schema instead.
- Run the Wrk Action test and inspect Extracted content in Test Results.
- Create Custom Outputs for the values downstream actions need. For the examples above,
$.emailselects the email address and$.orders[*].nameselects the order names from a nested list. - Use those named values from the Data Library in the next Wrk Action.
Troubleshooting
| Symptom | What to check |
|---|---|
null, {}, or [] instead of the expected value | Check the selector, the active page, the frame, and whether content has loaded. |
| Only one value is returned | Use type: "list" to read all matches. |
| Nested XPath repeats the same value in every item | Use an explicit relative XPath locator string, such as xpath=.//a. |
| A form value is outdated | Use value rather than @value. |
| Several iframes match | Use a more specific frame selector. |
| A table has fewer rows than expected | Load or scroll to the remaining rows before extraction. |
Related resources
- Working with Wrk's selection methods: choose locator strings for web actions.
- Custom Outputs: create named values from extracted content.
- Working with JSONPath: select nested values and filter arrays in Custom Outputs.
- Check element: check that page content is ready before extraction.