import { chromium } from 'playwright-core'; import { PAGE } from './paths.mjs'; const b = await chromium.launch({ executablePath: process.env.CH }); const p = await b.newPage({ viewport: { width: 1440, height: 900 } }); const errs = []; p.on('pageerror', e => errs.push(e.message)); await p.goto(PAGE('site/index.html')); await p.waitForTimeout(1200); const run = async (loc, anchor, ms) => { await p.fill('#byoA', loc); await p.selectOption('#byoB', { label: anchor }); await p.fill('#byoT', ms); await p.click('#byo button.go'); await p.waitForTimeout(200); return (await p.innerText('#byoout')).replace(/\s+/g, ' ').slice(0, 330) }; const opts = await p.$$eval('#byoB option', o => o.map(x => x.textContent)); console.log('anchors offered:', opts.length); console.log('1', await run('Detroit, US', opts.find(o => o.startsWith('Sydney')), '197.4')); console.log('2', await run('Southfield', opts.find(o => o.startsWith('Auckland')), '222.3')); console.log('3', await run('-33.87, 151.21', opts.find(o => o.startsWith('Auckland')), '25')); console.log('4', await run('Nowhereville', opts.find(o => o.startsWith('Sydney')), '20')); console.log('ERRORS', JSON.stringify(errs)); await b.close();