Repository navigation
Conversation
selectElementOptions deselected every option when none matched the requested values, so a single <select> fell back to its first option (and a multi-select was cleared), input/change fired, and the call reported that option as selected. Leave the selection untouched and reject instead.
🦋 Changeset detectedLatest commit: 4bd81ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
why
When none of the requested values match an option,
locator.selectOption()deselects every option. A single<select>then falls back to its first option, and a multi-select is cleared.inputandchangestill fire, and the call resolves with that first option's value as if it had been chosen:The same path backs
act()'sselectOptionFromDropdown. A model value that is slightly off (a typo, or a label that doesn't match exactly) silently submits the wrong choice, andact()reports success. #2953 works around this with a snapshot read-back ("selectOption reports success even when nothing matched"). The Playwright migration guide listsselectOption()as "Same names", and Playwright throws in this case.what changed
selectElementOptionsreturnsnullwithout touching the selection when values were requested but no option matches them.selectOption([])still clears a multi-select.Locator.selectOptionthrowsFailed to select option (no option matches [...]) for selector: ...on thatnull.act()already logs and rethrows selection errors.changeevent fires.test plan
pnpm exec vitest run -c vitest.integration.config.ts packages/sdk-ts/tests/integration/locatorSelectOption.test.ts: the new test fails before the fix (promise resolved "[ 's' ]" instead of rejecting). After the fix, 11/11 pass.just checkpasses.pnpm --filter ./packages/extension test:unit: 1054 passed.pnpm --filter ./packages/sdk-ts test:unit: 579 passed.pnpm --filter ./packages/sdk-ts test:browser: 25 passed, 18 skipped. OnlyrpcClientExtensionSmokefails, and it fails on main too (path contains a space).pytest: 1052 passed, 5 skipped.Summary by cubic
Rejects
locator.selectOption()when no option matches the requested values, instead of silently resetting the<select>to its first option (or clearing a multi-select) and reporting success.Previously, a single
<select>fell back to its first option and the call resolved as if that option was chosen, so a typo or slightly-off label could submit the wrong choice. Now the call throws, the current selection is left unchanged, and noinputorchangeevents fire. This aligns the behavior with Playwright, which throws in this case.Bug Fixes
selectElementOptionsreturnsnullwithout touching the selection when values were requested but none match;selectOption([])still clears a multi-select.Locator.selectOptionthrowsFailed to select option (no option matches [...]).changeevent fires.Written for commit 4bd81ee. Summary will update on new commits.