Appearance
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
| Parameter | Type | Description |
|---|---|---|
text | string | The text content to match. |
options? | FilterOptions | Optional 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']"