Skip to main content
Browser

Focus an element

Focus an element

Moves the browser's focus to a particular element on the page — the same as clicking into a field without triggering what a click would do. Useful for activating a field before typing or pressing a key.


Options

Select the action

The action's mode.

By browser

Focuses the element using a CSS selector on the page.

Browser or page ID

The browser, tab or iframe opening action used as the context.

Element selector

The CSS selector identifying the element to focus, input#name for example.

By element

Focuses an element captured earlier by a Get element action.

Element ID

The action that captured the element to focus.

By element list

Focuses an element from a list captured by a Get elements action.

Element list ID

The action that captured the list.

The list index

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

Returns

Javascript code

js
actions["action-id"] // the focused element (Element)

Field selection

Use this action's output to reference the focused element from other actions in the routine, such as Insert text or Press a key in By element mode.

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.
  • If the element is not found on the page, the action ends in an error.