Skip to content

Commit e84835c

Browse files
DavertMikclaude
andcommitted
fix(CDPBrowser): sync select/checked attributes for engines serializing forms from attributes
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 595a652 commit e84835c

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

lib/helper/clientscripts/cdpBrowserClient.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default function installCodeceptClient() {
119119
if (el.tagName === 'SELECT') {
120120
const opts = Array.from(el.options || [])
121121
let found = false
122-
if (el.multiple) {
122+
if (el.multiple || el.hasAttribute('multiple')) {
123123
opts.forEach(o => {
124124
const match = matches(o.value, o.textContent.trim())
125125
o.selected = match
@@ -133,6 +133,7 @@ export default function installCodeceptClient() {
133133
}
134134
}
135135
if (!found) return false
136+
opts.forEach(o => (o.selected ? o.setAttribute('selected', 'selected') : o.removeAttribute('selected')))
136137
fire(el, 'input')
137138
fire(el, 'change')
138139
return true

test/helper/webapi.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -539,56 +539,50 @@ export function tests() {
539539
})
540540

541541
describe('#selectOption', () => {
542-
it('should select option by css', async function () {
543-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
542+
it('should select option by css', async () => {
544543
await I.amOnPage('/form/select')
545544
await I.selectOption('form select[name=age]', 'adult')
546545
await I.click('Submit')
547546
assert.equal(formContents('age'), 'adult')
548547
})
549548

550-
it('should select option by name', async function () {
551-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
549+
it('should select option by name', async () => {
552550
await I.amOnPage('/form/select')
553551
await I.selectOption('age', 'adult')
554552
await I.click('Submit')
555553
assert.equal(formContents('age'), 'adult')
556554
})
557555

558-
it('should select option by label', async function () {
559-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
556+
it('should select option by label', async () => {
560557
await I.amOnPage('/form/select')
561558
await I.selectOption('Select your age', 'dead')
562559
await I.click('Submit')
563560
assert.equal(formContents('age'), 'dead')
564561
})
565562

566-
it('should select option by label and option text', async function () {
567-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
563+
it('should select option by label and option text', async () => {
568564
await I.amOnPage('/form/select')
569565
await I.selectOption('Select your age', '21-60')
570566
await I.click('Submit')
571567
assert.equal(formContents('age'), 'adult')
572568
})
573569

574-
it('should select option by label and option text - with an onchange callback', async function () {
575-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
570+
it('should select option by label and option text - with an onchange callback', async () => {
576571
await I.amOnPage('/form/select_onchange')
577572
await I.selectOption('Select a value', 'Option 2')
578573
await I.click('Submit')
579574
assert.equal(formContents('select'), 'option2')
580575
})
581576

582577
it('should select multiple options', async function () {
583-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
578+
if (isHelper('Obscura')) this.skip() // Obscura's form serializer collapses a <select multiple> submission to only its first selected option, regardless of the live .selected property or the selected attribute (verified: a single non-first selection round-trips fine, but two selections drop to one)
584579
await I.amOnPage('/form/select_multiple')
585580
await I.selectOption('What do you like the most?', ['Play Video Games', 'Have Sex'])
586581
await I.click('Submit')
587582
assert.deepEqual(formContents('like'), ['play', 'adult'])
588583
})
589584

590-
it('should select option by label and option text with additional spaces', async function () {
591-
if (isHelper('Obscura')) this.skip() // form submission does not pick up the live <select> state set by selectOption in Obscura
585+
it('should select option by label and option text with additional spaces', async () => {
592586
await I.amOnPage('/form/select_additional_spaces')
593587
await I.selectOption('Select your age', '21-60')
594588
await I.click('Submit')

0 commit comments

Comments
 (0)