fix: Easy Apply is an <a> not <button> — update selector; wait for element instead of fixed timeout
This commit is contained in:
@@ -18,19 +18,18 @@ export async function apply(page, job, formFiller) {
|
||||
|
||||
// Navigate to job page
|
||||
await page.goto(job.url, { waitUntil: 'domcontentloaded', timeout: NAVIGATION_TIMEOUT });
|
||||
await page.waitForTimeout(PAGE_LOAD_WAIT);
|
||||
|
||||
// Re-read meta
|
||||
// Wait for Easy Apply button to appear (up to PAGE_LOAD_WAIT)
|
||||
const eaBtn = await page.waitForSelector(LINKEDIN_APPLY_BUTTON_SELECTOR, { timeout: PAGE_LOAD_WAIT }).catch(() => null);
|
||||
if (!eaBtn) return { status: 'skipped_easy_apply_unsupported', meta };
|
||||
|
||||
// Re-read meta after page settled
|
||||
const pageMeta = await page.evaluate(() => ({
|
||||
title: document.querySelector('.job-details-jobs-unified-top-card__job-title, h1[class*="title"]')?.textContent?.trim(),
|
||||
company: document.querySelector('.job-details-jobs-unified-top-card__company-name a, .jobs-unified-top-card__company-name a')?.textContent?.trim(),
|
||||
}));
|
||||
Object.assign(meta, pageMeta);
|
||||
|
||||
// Verify Easy Apply button
|
||||
const eaBtn = await page.$(LINKEDIN_APPLY_BUTTON_SELECTOR);
|
||||
if (!eaBtn) return { status: 'skipped_easy_apply_unsupported', meta };
|
||||
|
||||
// Click Easy Apply
|
||||
await page.click(LINKEDIN_APPLY_BUTTON_SELECTOR, { timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
|
||||
await page.waitForTimeout(CLICK_WAIT);
|
||||
|
||||
Reference in New Issue
Block a user