Fix checkbox group (multi-select) handling in form filler
LinkedIn forms with "Select all that apply" questions use checkbox groups inside fieldsets. The fieldset handler only clicked one label (radio behavior). Now detects checkbox vs radio fieldsets and splits comma-separated AI answers to click multiple labels. Also added "consent" to auto-check keyword list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -409,12 +409,14 @@ Answer:`;
|
||||
}
|
||||
}
|
||||
|
||||
// Fieldsets (Yes/No radios)
|
||||
// Fieldsets (radios and checkbox groups)
|
||||
for (const fs of await container.$$('fieldset')) {
|
||||
const leg = await fs.$eval('legend', el => el.textContent.trim()).catch(() => '');
|
||||
if (!leg) continue;
|
||||
const anyChecked = await fs.$('input:checked');
|
||||
if (anyChecked) continue;
|
||||
// Detect if this is a checkbox group (multi-select) vs radio group
|
||||
const isCheckboxGroup = (await fs.$$('input[type="checkbox"]')).length > 0;
|
||||
// Collect option labels for AI context
|
||||
const labels = await fs.$$('label');
|
||||
const optionTexts = [];
|
||||
@@ -428,11 +430,23 @@ Answer:`;
|
||||
if (answer) this.saveAnswer(leg, answer);
|
||||
}
|
||||
if (answer) {
|
||||
for (const lbl of labels) {
|
||||
const text = await lbl.textContent().catch(() => '');
|
||||
if (text.trim().toLowerCase() === answer.toLowerCase()) {
|
||||
await lbl.click().catch(() => {});
|
||||
break;
|
||||
if (isCheckboxGroup) {
|
||||
// Multi-select: split comma-separated answers and click each matching label
|
||||
const selections = answer.split(',').map(s => s.trim().toLowerCase());
|
||||
for (const lbl of labels) {
|
||||
const text = (await lbl.textContent().catch(() => '') || '').trim();
|
||||
if (selections.some(s => text.toLowerCase() === s || text.toLowerCase().includes(s))) {
|
||||
await lbl.click().catch(() => {});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Single-select radio: click the matching label
|
||||
for (const lbl of labels) {
|
||||
const text = await lbl.textContent().catch(() => '');
|
||||
if (text.trim().toLowerCase() === answer.toLowerCase()) {
|
||||
await lbl.click().catch(() => {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -491,7 +505,7 @@ Answer:`;
|
||||
if (await cb.isChecked().catch(() => false)) continue;
|
||||
const lbl = await this.getLabel(cb);
|
||||
const ll = lbl.toLowerCase();
|
||||
if (ll.includes('top choice') || ll.includes('interested') || ll.includes('confirm') || ll.includes('agree')) {
|
||||
if (ll.includes('top choice') || ll.includes('interested') || ll.includes('confirm') || ll.includes('agree') || ll.includes('consent')) {
|
||||
await cb.check().catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user