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);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
export const NAVIGATION_TIMEOUT = 25000;
|
||||
export const SEARCH_NAVIGATION_TIMEOUT = 30000;
|
||||
export const FEED_NAVIGATION_TIMEOUT = 20000;
|
||||
export const PAGE_LOAD_WAIT = 3000;
|
||||
export const PAGE_LOAD_WAIT = 6000;
|
||||
export const SCROLL_WAIT = 1500;
|
||||
export const SEARCH_LOAD_WAIT = 5000;
|
||||
export const SEARCH_SCROLL_WAIT = 2000;
|
||||
@@ -24,7 +24,7 @@ export const APPLY_BETWEEN_DELAY_JITTER = 1000;
|
||||
// --- LinkedIn ---
|
||||
export const LINKEDIN_BASE = 'https://www.linkedin.com';
|
||||
export const LINKEDIN_EASY_APPLY_MODAL_SELECTOR = '[role="dialog"]';
|
||||
export const LINKEDIN_APPLY_BUTTON_SELECTOR = 'button[aria-label*="Easy Apply"]';
|
||||
export const LINKEDIN_APPLY_BUTTON_SELECTOR = '[aria-label*="Easy Apply"]';
|
||||
export const LINKEDIN_SUBMIT_SELECTOR = 'button[aria-label="Submit application"]';
|
||||
export const LINKEDIN_NEXT_SELECTOR = 'button[aria-label="Continue to next step"]';
|
||||
export const LINKEDIN_REVIEW_SELECTOR = 'button[aria-label="Review your application"]';
|
||||
|
||||
Reference in New Issue
Block a user