Skip to main content
Browser

Get an element's text

Get an element's text

Reads and returns an element's visible text from the browser's page. It works three ways: by CSS selector in the browser, on an element already captured, or on an item from a list of elements.

tip

Use the Roberty Automation browser extension to capture an element's CSS selector in one click.


Options

Select the action

Where the element comes from.

By browser

Reads the element's text using a CSS selector.

Browser or page ID

The browser, tab or iframe opening action the element is in.

Element selector

The CSS selector identifying the element on the page, span#total for example.

By element

Reads the text of an element captured earlier by a Get element action.

Element ID

The action that captured the element whose text is read.

By element list

Reads the text of an element from a list captured by a Get elements action.

Element list ID

The action that captured the source list.

The list index

The element's position in the list. The index starts at 0.

Returns

Javascript code

js
actions["action-id"].value // the element's visible text (Text)

Field selection

  • value — the visible text taken from the element, with no HTML markup (Text)

Rules and conditions

  • Select the action has to be set before the other fields.
  • In By browser mode, Browser or page ID and Element selector are both required.
  • What comes back is the element's visible content, with no HTML markup.
  • If the element is not found on the page, the action ends in an error.
  • If the element is there but has no text, the return is empty.