(async () => { const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const getAllDocuments = () => { const docs = [document]; const scan = doc => { [...doc.querySelectorAll("iframe, frame")].forEach(frame => { try { if (frame.contentDocument) { docs.push(frame.contentDocument); scan(frame.contentDocument); } } catch (e) {} }); }; scan(document); return docs; }; const waitForElement = async (selector, timeout = 15000) => { const start = Date.now(); while (Date.now() - start < timeout) { for (const doc of getAllDocuments()) { const el = doc.querySelector(selector); if (el) return el; } await sleep(300); } throw new Error(`No se encontrĂ³: ${selector}`); }; const clickElement = async selector => { const el = await waitForElement(selector); el.scrollIntoView({ block: "center", inline: "center" }); await sleep(300); el.click(); return el; }; await clickElement("#id_menu_prj_version_increment"); await sleep(1000); await clickElement('input[name="incrementar"][value="Increment"]'); })();