Skip to Content

getText

Get the text content of an element. Returns null if not found (soft fail).

Signature

const text = await utils.getText(selector, options?)

Parameters

ParamTypeDefaultDescription
selectorstring—CSS selector or XPath
options.waitTimeoutnumber0Max wait time for element (ms). Default: instant
options.frameFrame—Optional frame to search within

Examples

// Instant query const price = await utils.getText(".price"); if (price) console.log(`Price: ${price}`); // Wait for element to appear first const status = await utils.getText("#lazy-status", { waitTimeout: 8000 }); // Returns null if not found const missing = await utils.getText("#nonexistent"); // → null

Error Handling

Soft fail — returns null if element not found. Does not throw.

Last updated on