import puppeteer from 'puppeteer-extra'; import StealthPlugin from 'puppeteer-extra-plugin-stealth'; import { Browser, Page } from 'puppeteer'; puppeteer.use(StealthPlugin()); async function debugAfterStateSelect() { let browser: Browser | null = null; try { const url = 'https://curaleaf.com/stores/curaleaf-az-48th-street'; browser = await puppeteer.launch({ headless: 'new', args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-blink-features=AutomationControlled' ] }); const page = await browser.newPage(); await page.setViewport({ width: 1920, height: 1080 }); await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); console.log('Loading page...'); await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 }); await page.waitForTimeout(5000); // Click dropdown and select Arizona const stateButton = await page.$('button#state'); if (stateButton) { console.log('Clicking state button...'); await stateButton.click(); await page.waitForTimeout(800); console.log('Clicking Arizona...'); await page.evaluate(() => { const options = Array.from(document.querySelectorAll('[role="option"]')); const arizona = options.find(el => el.textContent?.toLowerCase() === 'arizona'); if (arizona instanceof HTMLElement) { arizona.click(); } }); await page.waitForTimeout(1000); console.log('\n=== AFTER selecting Arizona ==='); // Check what buttons are now visible const elementsAfter = await page.evaluate(() => { return { buttons: Array.from(document.querySelectorAll('button')).map(b => ({ text: b.textContent?.trim(), classes: b.className, id: b.id, visible: b.offsetParent !== null })), links: Array.from(document.querySelectorAll('a')).filter(a => a.offsetParent !== null).map(a => ({ text: a.textContent?.trim(), href: a.href })), hasAgeQuestion: document.body.textContent?.includes('21') || document.body.textContent?.includes('age') }; }); console.log('\nVisible buttons:', JSON.stringify(elementsAfter.buttons.filter(b => b.visible), null, 2)); console.log('\nVisible links:', JSON.stringify(elementsAfter.links, null, 2)); console.log('\nHas age question:', elementsAfter.hasAgeQuestion); } await browser.close(); process.exit(0); } catch (error) { console.error('Error:', error); if (browser) await browser.close(); process.exit(1); } } debugAfterStateSelect();