fix(locator): improve error message when unchecking radio buttons#37184
Merged
dgozman merged 4 commits intomicrosoft:mainfrom Aug 29, 2025
Merged
fix(locator): improve error message when unchecking radio buttons#37184dgozman merged 4 commits intomicrosoft:mainfrom
dgozman merged 4 commits intomicrosoft:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
dgozman
reviewed
Aug 28, 2025
Collaborator
dgozman
left a comment
There was a problem hiding this comment.
Thank you for the PR! This looks good overall, but bots are unhappy. Could you please address the linter and my comment?
| }; | ||
|
|
||
| const isRadio = async () => { | ||
| const result = await progress.race(this.evaluateInUtility(([injected, node]) => injected.isRadioButton(node), {})); |
Collaborator
There was a problem hiding this comment.
Could you please merge this evaluate into isChecked()?
Contributor
Author
There was a problem hiding this comment.
@dgozman Yes, done! I merged the radio button detection into the existing elementState('checked') call instead of making a separate evaluation. Now it returns both the checked state and radio button type in a single browser call, which is more efficient. Thanks..
This patch improves the error message when attempting to uncheck radio buttons using uncheck(), setChecked(false), or page.uncheck(). Previously, these operations would fail with a confusing error message "Clicking the checkbox did not change its state" that didn't clearly explain why the operation failed. Radio buttons cannot be unchecked by clicking - they can only be unchecked by selecting another radio button in the same group. The new error message clearly explains this behavior and guides users toward the correct approach. Changes: - Enhanced ElementStateQueryResult type to include isRadio property - Modified elementState method to detect radio buttons when checking state - Added radio button detection in _setChecked method to throw clear error Before: Error: locator.uncheck: Clicking the checkbox did not change its state After: Error: locator.uncheck: Cannot uncheck radio button. Radio buttons can only be unchecked by selecting another radio button in the same group.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
Test results for "tests 1"3 flaky46706 passed, 805 skipped Merge workflow run. |
dgozman
approved these changes
Aug 29, 2025
Collaborator
dgozman
left a comment
There was a problem hiding this comment.
Looks great, merging in. Thank you for the PR!
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.
fix(locator): improve error message when unchecking radio buttons
This patch improves the error message when attempting to uncheck radio buttons using uncheck(), setChecked(false), or page.uncheck(). Previously, these operations would fail with a confusing error message "Clicking the checkbox did not change its state" that didn't clearly explain why the operation failed.
Radio buttons cannot be unchecked by clicking - they can only be unchecked by selecting another radio button in the same group. The new error message clearly explains this behavior and guides users toward the correct approach.
Before: Error: locator.uncheck: Clicking the checkbox did not change its state
After: Error: locator.uncheck: Cannot uncheck radio button. Radio buttons can only be unchecked by selecting another radio button in the same group.
Changes:
isRadioButton()utility method to injected script for radio button detection_setChecked()method in ElementHandle to detect radio buttons and provide clear error messagingTesting:
Fixes #37178