Normalize fieldset legend text same as getLabel (dedup, strip Required)
Legend text was saved to answers.json with duplicated text and "Required" suffix, causing pattern mismatches on future runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -411,7 +411,16 @@ Answer:`;
|
||||
|
||||
// Fieldsets (radios and checkbox groups)
|
||||
for (const fs of await container.$$('fieldset')) {
|
||||
const leg = await fs.$eval('legend', el => el.textContent.trim()).catch(() => '');
|
||||
const leg = await fs.$eval('legend', el => {
|
||||
let raw = (el.textContent || '').replace(/\s+/g, ' ').replace(/\s*\*\s*$/, '').replace(/\s*Required\s*$/i, '').trim();
|
||||
if (raw.length > 8) {
|
||||
for (let len = Math.ceil(raw.length / 2); len >= 4; len--) {
|
||||
const candidate = raw.slice(0, len);
|
||||
if (raw.startsWith(candidate + candidate)) { raw = candidate.trim(); break; }
|
||||
}
|
||||
}
|
||||
return raw;
|
||||
}).catch(() => '');
|
||||
if (!leg) continue;
|
||||
const anyChecked = await fs.$('input:checked');
|
||||
if (anyChecked) continue;
|
||||
|
||||
Reference in New Issue
Block a user