← back to Nationalrealestate
cap_webkit.cjs
30 lines
const { webkit, devices } = require('playwright');
(async () => {
const url = process.argv[2] || 'https://corkwallcovering.com/';
const q = process.argv[3] || 'grasscloth';
let b;
try { b = await webkit.launch(); } catch(e){ console.log('WEBKIT-UNAVAILABLE', e.message.slice(0,120)); process.exit(3); }
const ctx = await b.newContext({ ...devices['iPhone 13'] });
const page = await ctx.newPage();
const errs = [];
page.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,120)); });
page.on('pageerror', e => errs.push('PAGEERR '+e.message.slice(0,120)));
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 }).catch(e=>errs.push('GOTO '+e.message.slice(0,80)));
await page.waitForTimeout(2500);
const sel = '#grid a.card, #grid .card, [data-card]';
const t = async () => page.$$eval(sel, els => els.slice(0,4).map(e=>(e.textContent||'').replace(/\s+/g,' ').trim().slice(0,28))).catch(()=>[]);
const vis = await page.isVisible('#searchInput').catch(()=>false);
const before = await t();
let typed=false;
try { await page.click('#searchInput',{timeout:4000}); await page.type('#searchInput', q, {delay:120}); typed=true; } catch(e){ errs.push('TYPE '+e.message.slice(0,70)); }
await page.waitForTimeout(1800);
const after = await t();
const stat = await page.$eval('#statLine', el=>el.textContent).catch(()=>'(none)');
console.log('ENGINE: WebKit(iOS Safari) |', url);
console.log('searchInput visible:', vis, '| typed:', typed);
console.log('grid changed on type:', JSON.stringify(before)!==JSON.stringify(after));
console.log('statLine:', String(stat).trim());
console.log('console/page errors:', errs.length? errs : 'NONE');
await b.close();
})().catch(e=>{console.error('ERR',e.message);process.exit(1);});