import {chromium} from 'playwright'; const b = await chromium.launch({channel: 'chrome'}); const p = await b.newPage({viewport: {width: 390, height: 780}, isMobile: true, hasTouch: true}); await p.goto('http://localhost/s/stay', {waitUntil: 'domcontentloaded'}); await p.waitForTimeout(5000); const box = await p.evaluate(() => { const rail = [...document.querySelectorAll('#gallery *')].find((el) => { const s = getComputedStyle(el); return /auto|scroll/.test(s.overflowX) && el.scrollWidth - el.clientWidth > 40; }); if (!rail) return null; rail.scrollIntoView({block: 'center'}); rail.dataset.w4dTest = '1'; const r = rail.getBoundingClientRect(); return {x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2)}; }); await p.waitForTimeout(700); const read = () => p.evaluate(() => Math.round(document.querySelector('[data-w4d-test]').scrollLeft)); // ① 손 안 대고 두는 동안 자동으로 넘어가는지 (자동 넘김이 살아 있는지 확인) const idle = []; for (let i = 0; i < 6; i++) { await p.waitForTimeout(1000); idle.push(await read()); } console.log('손 안 댐 →', JSON.stringify(idle)); // ② 진짜 터치로 스와이프한 뒤 await p.touchscreen.tap(box.x, box.y); await p.mouse.move(box.x + 120, box.y); await p.mouse.down(); await p.mouse.move(box.x - 100, box.y, {steps: 12}); await p.mouse.up(); await p.waitForTimeout(600); const afterSwipe = await read(); const log = []; for (let i = 0; i < 8; i++) { await p.waitForTimeout(1000); log.push(await read()); } console.log('스와이프 후', afterSwipe, '→', JSON.stringify(log), '· 자동 이동량', log[log.length - 1] - afterSwipe); await b.close();