RadioGroup: individual radio options are not testable with Playwright #3793
Replies: 2 comments 1 reply
-
| The issue here is that <RadioGroup.Item value="foo"> <RadioGroup.ItemText>Foo</RadioGroup.ItemText> <RadioGroup.ItemControl /> <RadioGroup.ItemHiddenInput /> // ← add this </RadioGroup.Item>With |
Beta Was this translation helpful? Give feedback.
-
| Hi @segunadebayo, thank you for the quick response! Adding However, this suggestion doesn't fully solve my issue. My current workarounds is using Can you please consider an alternative to the TL;DR for anyone who's encountering this: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
RadioGroup.Itemrenders the<input type="radio">as visually hidden. There is no way to target a specific radio option using Playwright's standard getBy* locators:getByRole('radio', { name: 'Foo' }): doesn't match. The hidden input has noaria-labelledbylinking it to the item text.getByRole('radio'): finds all radios, but no way to filter by value. All inputs share the same HTMLnameattribute bc ofRadioGroup.Itemtargeting "The name of the input fields in the radio (Useful for form submission)".getByLabel('Foo')/getByText('Foo'): finds the<span>or<label>, not the<input>with radio role.The only workaround is
.locator('[value="foo"]'), which bypasses role-based testing entirely.Link to Reproduction (or Detailed Explanation)
https://codesandbox.io/p/devbox/lucid-meadow-jclf58
Steps to Reproduce
<span id="...:radio:label:foo">Foo</span>exists but the associated<input type="radio">has noaria-labelledbypointing to it.document.querySelector('input[value="foo"]')has no accessible name.Ark UI Version
5.x.x
Framework
Browser
Google Chrome
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions