- Added 9 new tools: visual overlay, highlight, toast, drag-drop, etc. - Fixed evaluateJS to support function arguments - Fixed hover for non-visible elements - Fixed storage operations with try/catch - Added 10 new wait tools: clickable, element visible, text - Fixed tool name mapping in server.js for MCP protocol - Updated README with 60+ tools documentation - Version bump to 3.1.1
25 lines
743 B
JavaScript
25 lines
743 B
JavaScript
const browser = require('../browser');
|
|
|
|
module.exports = async ({ text, timeout = 15000 }) => {
|
|
if (!text) throw new Error('Texto é obrigatório');
|
|
await browser.start();
|
|
|
|
const p = await browser.ensurePage();
|
|
await p.waitForFunction((t) => {
|
|
return document.body.innerText.toLowerCase().includes(t.toLowerCase());
|
|
}, text, { timeout });
|
|
|
|
const found = await p.evaluate((t) => {
|
|
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
|
let node;
|
|
while (node = walker.nextNode()) {
|
|
if (node.textContent.toLowerCase().includes(t.toLowerCase())) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}, text);
|
|
|
|
return { success: true, action: 'wait_for_text', text, found };
|
|
};
|