Skip to content

Function: makeXPathSelector()

ts
function makeXPathSelector(text: string, options?: FilterOptions): string;

Defined in: src/utils/makeXPathSelector.ts:25

Create an XPath selector that matches elements containing the given text.

Parameters

ParameterTypeDescription
textstringThe text content to match.
options?FilterOptionsOptional filter options.

Returns

string

The XPath selector string.

Example

ts
const xpath = makeXPathSelector('Add to Cart');
// "//*[normalize-space(text()) = 'Add to Cart']"

const xpath2 = makeXPathSelector('Submit', { filterElementWithTag: 'button' });
// "//button[normalize-space(text()) = 'Submit']"

Matterway Assistant SDK Documentation