Checkboxes & Radio Buttons Demo
1. Standard Controls
Checkboxes (Multi-select)
Select one or more skills you know:
locator.check() and locator.uncheck() to toggle checkboxes.
Radio Buttons (Single-select)
Select your preferred plan:
name attribute.
2. State-Based Scenarios
Default States
Notification preference (pre-selected):
expect(locator).toBeChecked() immediately upon page load to verify default states.
Disabled States
expect(locator).toBeDisabled().
Indeterminate State
The "Select All" checkbox shows a dash when only some items are selected:
locator.evaluate(el => el.indeterminate).
3. Locator Challenges
Labels and IDs
Properly labeled inputs for better accessibility:
page.getByLabel('Receive product updates') instead of brittle CSS selectors like #receive-updates.
Hidden Inputs (Custom Styling)
Fancy checkboxes with hidden native inputs:
<input> is hidden (opacity: 0), you might need { force: true } option or click the label instead.
4. Dynamic Interactions
Dependent Fields
Checking this box will enable additional options:
Delayed Loading
These checkboxes appear after a 2-second delay:
5. Edge Cases
The "I Agree" Trap
Scroll to the bottom of the terms to enable the checkbox:
Terms and Conditions
By using this service, you agree to the following terms and conditions:
1. You will use this platform responsibly and in accordance with all applicable laws.
2. You understand that this is a demo application for testing purposes.
3. Any data entered may be visible to other users of the platform.
4. We reserve the right to modify these terms at any time.
5. Your use of automated testing tools is encouraged and expected.
6. All test data should be anonymized and non-sensitive.
7. Please report any bugs or issues you encounter.
8. This platform is provided "as is" without warranty of any kind.
9. We are not responsible for any data loss or damage.
END OF TERMS - You have reached the bottom!
element.scrollIntoView() or scroll events.
Shadow DOM Challenge
Radio buttons wrapped in Shadow DOM:
Current Selections
Make some selections above to see them displayed here...