Skip to content

Element Location and Selectors

Nodes that click, type, hover, or read page content must identify a webpage element. RPA Plus can locate it again on the active page or reference an element object saved by an upstream node.

Select an Element Source

Element-based nodes provide sources according to their function:

SourceBehaviorSuitable use
Element selectorSearches the active page again when the node runsThe page structure is stable or the current page target must be found each time
Saved element objectUses an element variable output by an upstream nodeA focused element, DOM object, or current loop element is already available

After selecting a saved element object, select its variable without entering another selector.

Element selector configuration
Element selector configuration
Saved element object configuration
Saved element object configuration

Select a Location Method

CSS Selector

A CSS selector works well when a page has a stable id, class, or attribute.

css
#login-button
.product-card
input[name="email"]

Prefer stable attributes that express a business meaning. Avoid frequently changing generated class names or unnecessarily long hierarchy paths.

XPath

XPath locates an element using hierarchy, attributes, or text relationships and is useful when a CSS selector cannot express the required structure.

text
//button[@type="submit"]
//div[@data-role="product"]//span[@class="price"]

XPath is sensitive to structural changes. Relative paths with stable attributes are more resilient to small page changes.

To obtain a CSS selector or XPath from a webpage, see Get a CSS Selector or XPath.

Text Content

Text location searches displayed text and is suitable for buttons, menus, and stable labels.

text
Sign in now
Submit order

When the same text appears more than once, specify an element index or use a more precise CSS selector or XPath.

CSS selector location
CSS selector location
XPath location
XPath location
Text content location
Text content location
RuleSuitable useRecommendation
CSS SelectorThe page has a stable id, class, or attributePrefer business attributes over generated class names
XPathHierarchy, attribute, or text relationships are requiredUse a relative path to reduce sensitivity to structural changes
Text contentA button, menu, or label has stable, mostly unique textAdd an element index for duplicates or use a more precise rule

Select a Matching Element

One selector can match several elements. Select the operation target with either method.

Fixed Index

Enter the natural position in the results; for example, 1 selects the first match. A fixed index can use a workflow variable.

Use it when structure and order are stable, such as clicking the first search result.

Random Range

Enter a minimum and maximum index. At runtime, RPA Plus randomly selects a matching element in that range. For example, 1 through 5 chooses one of the first five matches.

Before using a random range, ensure the page has enough matching elements. Otherwise reduce the maximum or wait for the page content to load.

Fixed element index
Fixed element index
Random element index range
Random element index range
ExampleConfigurationResult
Fixed 2Fixed index: 2Always selects the second matching element
Random 1-3Minimum: 1; maximum: 3Randomly selects one of the first three matches

Use a Variable in a Selector

A selector field marked as variable-enabled can include system or visible workflow variables. When product_id is 10001, this creates a complete selector:

css
[data-product-id="${product_id}"]

Use the variable button beside the field to avoid syntax mistakes. Only variables produced upstream of the active node appear.

Use a Saved Element Object

These nodes can produce element objects:

  • Get Element Data when returning a DOM object or another element result.
  • Get Focused Element for the element currently focused on the page.
  • For Each Element for the DOM object of the active loop element.

A downstream node that supports element objects can select the variable directly:

text
Get Element Data → Click Element

An element object is not plain text or manually authored JSON. It represents an element in the active page session and is available only on downstream paths from its source.

Reference a saved element object
Reference a saved element object

Common Scenarios

Enter an Account Name

  1. Add Enter Text.
  2. Select Element Selector as the source.
  3. Select CSS Selector as the location method.
  4. Enter input[name="username"].
  5. Reference the account variable as the input value.

Click One Item in a Repeated List

  1. Match every Open button with .result-item .open-button.
  2. Select Fixed Index.
  3. Enter 1 and validate the first result.
  4. After debugging, replace it with a variable or random range if required.

Operate on the Focused Element

  1. Use Get Focused Element and save the result as focused_element.
  2. Select Saved Element Object in a downstream Enter Text or Click Element node.
  3. Select focused_element; no CSS selector or XPath is required.

Improve Location Stability

  • Prefer business attributes such as name, data-*, or a stable id.
  • Avoid generated class names and absolute XPath.
  • Add Wait for Element before an action on a slow page.
  • For an element inside an iframe, ensure the extraction or location configuration uses the correct page context.
  • When a selector matches several elements, explicitly configure a fixed index or random range.
  • Debug again after page structure changes rather than relying on a selector that worked previously.

Troubleshooting

Element Not Found During Debugging

Confirm that navigation is complete, the selector matches the active page, and the target is visible. Add Wait for Element and increase the timeout if required.

Selector Matches the Wrong Element

Narrow the CSS selector or XPath and check the element index. Use a stable attribute instead of duplicated text.

Element Object Variable Is Unavailable

Confirm that the upstream node outputs an element and the active node is on a reachable downstream path. A string, object, or variable produced later does not appear in the element object list.

Selector Breaks After a Page Update

Inspect the DOM again and use a more stable attribute. For a changing list, prefer a relative rule inside the list container over a full hierarchy and fixed position.