← back to Charge And Explore

support-form/step5-challenge-shot.cjs

22 lines

// Step 5: screenshot the hCaptcha challenge iframe at native size and report
// its bounding box so tiles can be clicked by coordinates.
const { chromium } = require('/Users/macstudio3/uber-address-fix/node_modules/playwright');

(async () => {
  const browser = await chromium.connectOverCDP('http://127.0.0.1:9223');
  const ctx = browser.contexts()[0];
  const page = ctx.pages().find(p => p.url().includes('auth.tesla.com'));
  if (!page) { console.error('no tesla tab'); process.exit(1); }

  const frames = await page.$$('iframe');
  for (const f of frames) {
    const src = await f.getAttribute('src') || '';
    const box = await f.boundingBox();
    if (src.includes('hcaptcha') && box && box.width > 300) {
      console.log('CHALLENGE IFRAME box:', JSON.stringify(box));
      await f.screenshot({ path: __dirname + '/s5-challenge.png' });
    }
  }
  process.exit(0);
})().catch(e => { console.error('ERR', e.message); process.exit(1); });