-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Indeterminate state test for checkboxes #33946
Comments
It is absolutely wrong to consider indeterminate as checked. That's like saying, at a junction where you can turn left, right or go straight ahead, we just always treat left as right. |
@Bilge as a workaround, you can use this: await expect(page.locator('input')).toMatchAriaSnapshot('- checkbox [checked=mixed]'); |
Well, not really. It's more like saying "At an intersection where you can go left or right, and there's a dirt road that goes straight ahead, we treat left as left, right and the dirt road as right" |
🚀 Feature Request
Playwright (incorrectly) assumes checkboxes are binary; they are not. The default checkbox may specify the indeterminate state, in which it is neither checked nor unchecked. Moreover,
aria-checked
may specifymixed
(in addition totrue
orfalse
). The Playwright API seems completely ignorant of the third state, such thatlocator.toBeChecked()
cannot test for it andlocator.setChecked()
cannot set it.It is important to have an ARIA-compatible test for this, since there is no guarantee custom control will implement the mechanism using the indeterminate property; the only requirement is that they set
aria-checked
tomixed
.Example
expect(check).toBeChecked({checked: 'indeterminate'});
OR
expect(check).toBeChecked({checked: 'mixed'});
OR
expect(check).toBeChecked({indeterminate: true});
OR
expect(check).toBeIndeterminate();
Motivation
It is difficult to test the state of a tri-state checkbox without an ARIA-compatible API.
The text was updated successfully, but these errors were encountered: