playwright-fluent
Version:
Fluent API around playwright
22 lines (21 loc) • 752 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHandlesWithExactText = void 0;
async function getHandlesWithExactText(text, handles) {
const result = [];
for (let index = 0; index < handles.length; index++) {
const handle = handles[index];
const innerText = await handle.evaluate((node) => {
const nodeWithText = node;
if (nodeWithText && typeof nodeWithText.innerText === 'string') {
return nodeWithText.innerText.replace(/\s/g, ' ');
}
return '';
});
if (innerText === text) {
result.push(handle);
}
}
return result;
}
exports.getHandlesWithExactText = getHandlesWithExactText;
;