diff --git a/lib/apply/easy_apply.mjs b/lib/apply/easy_apply.mjs index 50b213e..7212578 100644 --- a/lib/apply/easy_apply.mjs +++ b/lib/apply/easy_apply.mjs @@ -120,10 +120,10 @@ export async function apply(page, job, formFiller) { el => el.getAttribute('aria-valuenow') || el.getAttribute('value') || el.style?.width || '' ).catch(() => ''); - // Debug snapshot: heading, buttons in modal, and any validation errors + // Debug snapshot: heading, buttons in modal, iframes, and any validation errors const debugInfo = await page.evaluate((sel) => { const modal = document.querySelector(sel); - if (!modal) return { heading: '', buttons: [], errors: [] }; + if (!modal) return { heading: '', buttons: [], errors: [], iframes: 0, childTags: '', htmlSnippet: '' }; const heading = modal.querySelector('h1, h2, h3, [class*="title"], [class*="heading"]')?.textContent?.trim()?.slice(0, 60) || ''; const buttons = Array.from(modal.querySelectorAll('button, [role="button"]')).map(b => ({ text: (b.innerText || b.textContent || '').trim().slice(0, 50), @@ -132,9 +132,17 @@ export async function apply(page, job, formFiller) { })).filter(b => b.text || b.aria); const errors = Array.from(modal.querySelectorAll('[class*="error"], [aria-invalid="true"], .artdeco-inline-feedback--error')) .map(e => e.textContent?.trim().slice(0, 60)).filter(Boolean); - return { heading, buttons, errors }; - }, MODAL).catch(() => ({ heading: '', buttons: [], errors: [] })); + const iframes = modal.querySelectorAll('iframe').length; + // Top-level child tags for structure debugging + const childTags = Array.from(modal.children).map(c => c.tagName.toLowerCase() + (c.className ? '.' + c.className.split(' ')[0] : '')).join(', '); + const htmlSnippet = modal.innerHTML.slice(0, 500); + return { heading, buttons, errors, iframes, childTags, htmlSnippet }; + }, MODAL).catch(() => ({ heading: '', buttons: [], errors: [], iframes: 0, childTags: '', htmlSnippet: '' })); console.log(` [step ${step}] progress=${progress} heading="${debugInfo.heading}" buttons=${JSON.stringify(debugInfo.buttons)}${debugInfo.errors.length ? ' errors=' + JSON.stringify(debugInfo.errors) : ''}`); + if (step === 0) { + console.log(` [diag] iframes=${debugInfo.iframes} children=[${debugInfo.childTags}]`); + console.log(` [diag] html=${debugInfo.htmlSnippet}`); + } // Fill form fields const unknowns = await formFiller.fill(page, formFiller.profile.resume_path);