import {chromium} from 'playwright'; const b = await chromium.launch({channel: 'chrome'}); for (const tag of ['desktop', 'mobile']) { const p = await b.newPage(tag === 'mobile' ? {viewport: {width: 390, height: 780}, isMobile: true, hasTouch: true} : {viewport: {width: 1280, height: 900}}); await p.goto('http://localhost/s/stay', {waitUntil: 'domcontentloaded'}); await p.waitForTimeout(5000); const before = await p.evaluate(() => ({ playing: document.getElementById('w4d-play').dataset.playing, title: document.getElementById('w4d-now')?.textContent, titleShown: document.getElementById('w4d-now') ? getComputedStyle(document.getElementById('w4d-now')).display : '-', })); await p.click('#w4d-play'); // ← 한 번만 누른다 await p.waitForTimeout(2500); const after = await p.evaluate(() => ({ playing: document.getElementById('w4d-play').dataset.playing, title: document.getElementById('w4d-now')?.textContent, icon: document.getElementById('w4d-play').querySelector('path')?.getAttribute('d')?.slice(0, 12), })); console.log(tag, '누르기 전', JSON.stringify(before), '→ 한 번 누른 뒤', JSON.stringify(after)); if (tag === 'desktop') { // 곡이 끝나면 다음 곡으로 (순차) — 끝 2초 앞으로 보낸다 const seq = await p.evaluate(async () => { const first = document.getElementById('w4d-now').textContent; const a = document.querySelector('audio') || null; // Audio 객체는 DOM 밖이라 이벤트로 끝을 흉내낸다 document.getElementById('w4d-next') ? null : null; const rows = [...document.querySelectorAll('.w4d-item')]; return {first, rows: rows.length}; }); console.log(' 현재 곡', JSON.stringify(seq)); } await p.close(); } await b.close();