debug: log apply elements on skip; use state=attached for waitForSelector

This commit is contained in:
2026-03-06 17:05:57 +00:00
parent 318da35e01
commit 8c626b5147

View File

@@ -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(() => ({