fix: click parent <a> link for Continue, not child <span>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 10:57:35 -08:00
parent 4c85a88902
commit 46c84bf28a

View File

@@ -114,15 +114,15 @@ export async function apply(page, job, formFiller) {
await page.evaluate(() => window.scrollTo(0, 300)).catch(() => {});
let eaBtn = await page.waitForSelector(LINKEDIN_APPLY_BUTTON_SELECTOR, { timeout: 12000, state: 'attached' }).catch(() => null);
// Fallback: LinkedIn shows plain "Continue" when a draft exists (not a button — a span)
// Look for it via the apply URL pattern in the page
// Fallback: LinkedIn shows plain "Continue" when a draft exists (span inside an <a>)
// Find the parent <a> link and click that, or navigate to the apply URL
if (!eaBtn) {
const continueEl = await page.$(`a[href*="/apply/"] span, [class*="apply"] span`);
if (continueEl) {
const text = await continueEl.evaluate(el => (el.innerText || '').trim()).catch(() => '');
if (text === 'Continue') {
eaBtn = continueEl;
console.log(` Found "Continue" element (draft application)`);
const applyLink = await page.$(`a[href*="/apply/"]`);
if (applyLink) {
const text = await applyLink.evaluate(el => (el.innerText || '').trim()).catch(() => '');
if (/continue/i.test(text)) {
eaBtn = applyLink;
console.log(` Found "Continue" link (draft application)`);
}
}
}