Fix date inputs and dismiss date picker/sub-form popups

- Start date fields now return mm/dd/yyyy format instead of "Immediately"
- Cancel any open sub-forms or date pickers before filling (handles
  stacked popups with double-cancel check)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 15:02:35 -08:00
parent 029360b118
commit fdb0224226
2 changed files with 18 additions and 7 deletions

View File

@@ -189,14 +189,19 @@ export async function apply(page, job, formFiller) {
const debugInfo = await getModalDebugInfo(page, MODAL);
console.log(` [step ${step}] progress=${progress} heading="${debugInfo.heading}" buttons=${JSON.stringify(debugInfo.buttons)}${debugInfo.errors.length ? ' errors=' + JSON.stringify(debugInfo.errors) : ''}`);
// LinkedIn sometimes opens an "Add education/experience" sub-form with Save/Cancel buttons.
// These block the main Next button. Dismiss them before filling.
const saveBtn = await findModalButton(page, MODAL, { ariaLabels: [], exactTexts: ['Save'] });
// LinkedIn sometimes opens sub-forms (education, experience, date pickers) with Cancel/Save.
// Dismiss them before filling to avoid filling sub-form fields.
const cancelBtn = await findModalButton(page, MODAL, { ariaLabels: [], exactTexts: ['Cancel'] });
if (saveBtn && cancelBtn) {
console.log(` [step ${step}] sub-form detected (Save/Cancel) — cancelling`);
if (cancelBtn) {
console.log(` [step ${step}] sub-form/picker detected — cancelling`);
await cancelBtn.click({ timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
await page.waitForTimeout(CLICK_WAIT);
// Check if another Cancel is still open (e.g. date picker behind education form)
const cancelBtn2 = await findModalButton(page, MODAL, { ariaLabels: [], exactTexts: ['Cancel'] });
if (cancelBtn2) {
await cancelBtn2.click({ timeout: APPLY_CLICK_TIMEOUT }).catch(() => {});
await page.waitForTimeout(CLICK_WAIT);
}
}
// Fill form fields — page.$() in form_filler pierces shadow DOM