d8796531ee
- 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
24 lines
891 B
JavaScript
24 lines
891 B
JavaScript
const browser = require('../browser');
|
|
|
|
module.exports = async ({ selector, timeout = 15000 }) => {
|
|
if (!selector) throw new Error('Selector é obrigatório');
|
|
await browser.start();
|
|
|
|
const p = await browser.ensurePage();
|
|
await p.waitForSelector(selector, { state: 'visible', timeout });
|
|
|
|
const result = await p.evaluate((sel) => {
|
|
const el = document.querySelector(sel);
|
|
if (!el) return { clickable: false, reason: 'not found' };
|
|
|
|
const rect = el.getBoundingClientRect();
|
|
const isVisible = rect.width > 0 && rect.height > 0;
|
|
const isEnabled = !el.disabled;
|
|
const isClickable = isVisible && isEnabled && window.getComputedStyle(el).pointerEvents !== 'none';
|
|
|
|
return { clickable: isClickable, visible: isVisible, enabled: isEnabled, rect };
|
|
}, selector);
|
|
|
|
return { success: true, action: 'wait_for_clickable', selector, ...result };
|
|
};
|