modal-shot.mjs (1018B)
1 // Ouvre une modale et capture, pour vérifier la mise en page (filtres sur une ligne, croix à droite). 2 // node test/modal-shot.mjs <programmes|exelmemoire> [url] [capture.png] 3 import { open, sleep } from './cdp.mjs'; 4 const which = process.argv[2] ?? 'programmes'; 5 const url = process.argv[3] ?? 'http://127.0.0.1:8195/'; 6 const shot = process.argv[4] ?? '/tmp/modal.png'; 7 const page = await open(url, { width: 1100, height: 1200 }); 8 await sleep(7000); 9 await page.evaluate(which === 'exelmemoire' ? "document.getElementById('cram-open').click()" : "document.getElementById('pick').click()"); 10 await sleep(500); 11 const chipLines = await page.evaluate(`(() => { 12 const chips = [...document.querySelectorAll('#chips .chip')]; 13 const tops = new Set(chips.map((c) => c.getBoundingClientRect().top)); 14 return { chips: chips.length, lines: tops.size }; 15 })()`).catch(() => null); 16 if (chipLines) console.log('filtres :', JSON.stringify(chipLines)); 17 await page.screenshot(shot); 18 console.log('Capture :', shot); 19 page.close();