Skip to content

Variable: getText()

ts
const getText: (ctx: Context, selector: string, options?: GetValueOptions) => Promise<string> = getValue;

Defined in: src/dom/index.ts:113

Return the text content of an element. For input fields, use getValue instead.

Return the value of a form element.

Parameters

ParameterTypeDescription
ctxContextContext object.
selectorstringCSS or XPath selector for the target element.
options?GetValueOptionsOptions for waiting and querying. Supports root to specify a root element.

Returns

Promise<string>

The value of the form element as a string.

Example

ts
// Read the customer name from a CRM form
const customerName = await getValue(ctx, 'input[name="customerName"]');
console.log(`Hello, ${customerName}!`);

Example

ts
// Grab the page heading to verify we landed on the right page
const heading = await getText(ctx, 'h1.page-title');

Param

Context object.

Param

CSS or XPath selector for the target element.

Returns

The text content as a string.

Matterway Assistant SDK Documentation