Fix radio selection: verify click worked, fallback to input/select
LinkedIn radio clicks via label can silently fail. Now verifies input:checked after label click, falls back to clicking radio input directly by value match, and tries <select> within fieldset as last resort. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -440,14 +440,37 @@ Answer:`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Single-select radio: click the matching label
|
||||
// Single-select radio: click the matching label, then verify
|
||||
let clicked = false;
|
||||
for (const lbl of labels) {
|
||||
const text = await lbl.textContent().catch(() => '');
|
||||
if (text.trim().toLowerCase() === answer.toLowerCase()) {
|
||||
const text = (await lbl.textContent().catch(() => '') || '').trim();
|
||||
if (text.toLowerCase() === answer.toLowerCase() ||
|
||||
text.toLowerCase().startsWith(answer.toLowerCase())) {
|
||||
await lbl.click().catch(() => {});
|
||||
clicked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Verify a radio got checked — if not, try clicking the input directly
|
||||
if (clicked) {
|
||||
const nowChecked = await fs.$('input:checked');
|
||||
if (!nowChecked) {
|
||||
const radios = await fs.$$('input[type="radio"]');
|
||||
for (const radio of radios) {
|
||||
const val = await radio.evaluate(el => el.value || el.nextSibling?.textContent?.trim() || '').catch(() => '');
|
||||
if (val.toLowerCase() === answer.toLowerCase() ||
|
||||
val.toLowerCase().startsWith(answer.toLowerCase())) {
|
||||
await radio.click({ force: true }).catch(() => {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Last resort: try as a <select> within the fieldset
|
||||
if (!clicked || !(await fs.$('input:checked'))) {
|
||||
const sel = await fs.$('select');
|
||||
if (sel) await this.selectOptionFuzzy(sel, answer);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unknown.push(leg);
|
||||
|
||||
Reference in New Issue
Block a user