Skip to main content

Get web element by XPath

Sophie avatar
Written by Sophie
Updated over 2 weeks ago

Definition and Usage

This command locates and retrieves a specific element on a web page using XPath syntax. It allows you to identify and interact with web elements based on their position in the HTML document structure, making it useful for web automation tasks where elements need to be precisely targeted.


Parameter Values

Input parameters

Parameter

Description

Possible Values

Required

Options / Notes

Web page

Select a variable that contains the web page to work with

Any web page variable

Yes

Must be a previously opened web page

XPath

Enter the XPath to locate the target web element

Valid XPath expression

Yes

Use XPath syntax to identify the element

Element in iframe

Check this if the element is inside an iframe

True/False

No

When checked, additional iframe options appear

Iframe XPath

XPath of Iframe

Valid XPath expression

Only if "Element in iframe" is checked

Used to locate the iframe containing the target element

Advanced settings

Parameter

Description

Possible Values

Required

Options / Notes

Element timeout (s)

Wait time for element to appear (seconds)

Numeric value

No

Default is 20 seconds

Error handling

Parameter Name

Description

Throw error & stop

When an error occurs, the action will trigger an error and stop the execution of the entire app.

Retry command

If an error occurs, the action will retry the command in an attempt to resolve the issue and continue the process.

Ignore error & continue

When an error occurs, the action will be ignored, and the workflow will continue without interruption.

Variables produced

This action produces a web element object variable specified in the "Store web element into" field. This variable can be used in subsequent actions that require a web element as input.


Using Variables in Conditions

You can use variables in the XPath field by inserting them with the {variableName} syntax. This is particularly useful when the XPath needs to be dynamically determined based on previous operations or input data. The variable icon indicates where variables can be inserted.


Notes

  • Before using this command, ensure that the web page is properly loaded and accessible.

  • XPath expressions must be valid and correctly target the desired element.

  • If the element is not found within the specified timeout period, an error will occur.

  • For elements within iframes, both the iframe and the element within it must be correctly identified with XPath.

  • The web element object returned can be used for actions like clicking, extracting text, or checking properties.

Did this answer your question?