debug: add modal structure diagnostics — iframe detection, child tags, html snippet

Logs iframe count, child element tags, and first 500 chars of modal innerHTML
on step 0 to diagnose why buttons/heading aren't being found.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 10:13:22 -08:00
parent e6fb380e1c
commit 0df5eb1b63

View File

@@ -120,10 +120,10 @@ export async function apply(page, job, formFiller) {
el => el.getAttribute('aria-valuenow') || el.getAttribute('value') || el.style?.width || ''
).catch(() => '');
// Debug snapshot: heading, buttons in modal, and any validation errors
// Debug snapshot: heading, buttons in modal, iframes, and any validation errors
const debugInfo = await page.evaluate((sel) => {
const modal = document.querySelector(sel);
if (!modal) return { heading: '', buttons: [], errors: [] };
if (!modal) return { heading: '', buttons: [], errors: [], iframes: 0, childTags: '', htmlSnippet: '' };
const heading = modal.querySelector('h1, h2, h3, [class*="title"], [class*="heading"]')?.textContent?.trim()?.slice(0, 60) || '';
const buttons = Array.from(modal.querySelectorAll('button, [role="button"]')).map(b => ({
text: (b.innerText || b.textContent || '').trim().slice(0, 50),
@@ -132,9 +132,17 @@ export async function apply(page, job, formFiller) {
})).filter(b => b.text || b.aria);
const errors = Array.from(modal.querySelectorAll('[class*="error"], [aria-invalid="true"], .artdeco-inline-feedback--error'))
.map(e => e.textContent?.trim().slice(0, 60)).filter(Boolean);
return { heading, buttons, errors };
}, MODAL).catch(() => ({ heading: '', buttons: [], errors: [] }));
const iframes = modal.querySelectorAll('iframe').length;
// Top-level child tags for structure debugging
const childTags = Array.from(modal.children).map(c => c.tagName.toLowerCase() + (c.className ? '.' + c.className.split(' ')[0] : '')).join(', ');
const htmlSnippet = modal.innerHTML.slice(0, 500);
return { heading, buttons, errors, iframes, childTags, htmlSnippet };
}, MODAL).catch(() => ({ heading: '', buttons: [], errors: [], iframes: 0, childTags: '', htmlSnippet: '' }));
console.log(` [step ${step}] progress=${progress} heading="${debugInfo.heading}" buttons=${JSON.stringify(debugInfo.buttons)}${debugInfo.errors.length ? ' errors=' + JSON.stringify(debugInfo.errors) : ''}`);
if (step === 0) {
console.log(` [diag] iframes=${debugInfo.iframes} children=[${debugInfo.childTags}]`);
console.log(` [diag] html=${debugInfo.htmlSnippet}`);
}
// Fill form fields
const unknowns = await formFiller.fill(page, formFiller.profile.resume_path);