// «Copia in…» on the whole Libreria with «Cambia» open (spec §4.10, tappa E3; composed from the dialogs of mockup 13, // the segmented controls of mockup 07 and mockup 09): PNG chosen for the photos of this copy only, the summary and the // rows asked again with that format. Nothing is started. const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const until = async (test, tries = 100) => { for (let i = 0; i < tries && !test(); i++) await sleep(100); return test(); }; const button = () => [...document.querySelectorAll('.strumenti button')].find((b) => (b.getAttribute('aria-label') || '').startsWith('Esporta')); await until(() => button() && document.querySelector('.tess[data-id]')); button().click(); await sleep(400); [...document.querySelectorAll('.menu button, .menu [role=menuitem]')].find((x) => x.textContent.includes('Copia'))?.click(); const dialog = () => document.querySelector('.dialogo.copia-in'); await until(() => dialog()?.querySelector('.riepilogo-copia'), 150); dialog().querySelector('.riga-formato-testa .btn').click(); await sleep(200); dialog().querySelector('.riga-formato .scelta-formato[data-tipo=photo] [data-value=png]').click(); // The choice asks the plan again: the button is off until the new plan is drawn. await until(() => dialog().querySelector('.riepilogo-copia') && !dialog().querySelector('footer .btn.primo').disabled, 200); await sleep(400); document.activeElement?.blur(); return [dialog().querySelector('.testo-formato')?.textContent, dialog().querySelector('.riepilogo-copia')?.textContent];