diff --git a/lib/apply/easy_apply.mjs b/lib/apply/easy_apply.mjs index 77662fd..5425313 100644 --- a/lib/apply/easy_apply.mjs +++ b/lib/apply/easy_apply.mjs @@ -21,8 +21,16 @@ export async function apply(page, job, formFiller) { // Scroll slightly to trigger lazy-loaded content, then wait for Easy Apply button await page.evaluate(() => window.scrollTo(0, 300)).catch(() => {}); - const eaBtn = await page.waitForSelector(LINKEDIN_APPLY_BUTTON_SELECTOR, { timeout: 12000 }).catch(() => null); - if (!eaBtn) return { status: 'skipped_easy_apply_unsupported', meta }; + const eaBtn = await page.waitForSelector(LINKEDIN_APPLY_BUTTON_SELECTOR, { timeout: 12000, state: 'attached' }).catch(() => null); + if (!eaBtn) { + // Debug: log what apply-related elements exist + const applyEls = await page.evaluate(() => + Array.from(document.querySelectorAll('[aria-label*="Easy Apply"], [aria-label*="Apply"]')) + .map(el => ({ tag: el.tagName, aria: el.getAttribute('aria-label'), visible: el.offsetParent !== null })) + ).catch(() => []); + console.log(` ℹ️ No Easy Apply element found. Apply-related elements: ${JSON.stringify(applyEls)}`); + return { status: 'skipped_easy_apply_unsupported', meta }; + } // Re-read meta after page settled const pageMeta = await page.evaluate(() => ({