Documentation Index

Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt

Use this file to discover all available pages before exploring further.

Syntax for indexing XPath

Prev Next

Overview

The Syntax for indexing XPath differs when used directly to reference an individual element on a page as opposed to xxxxxxxx. In such scenarios, it is necessary to use "()" to specify the element is being referenced globally.

Examples

indexing use for child element

XPath: //div[@class="blue"]/div[@class="red"][2]

In the above example, a div element with class="blue" will be located. Next, it will search for the immediate child div element with class="red" and will select the second match.

global reference

(//div[@class="red"])[2]

In the above example, all div elements with class="red" will be located. Use of ()[2] specifies to select the second match of the returned result.

See also:
Scripting Tips and Best Practices