← Back to library
Playwrightformsbeginnerv1.20+

Select a radio button

Pick a radio option by accessible name and confirm mutually exclusive selection.

1test('selects express shipping radio', async ({ page }) => {
2  await page.goto('/checkout');
3
4  await page.getByRole('radio', { name: 'Express shipping' }).check();
5  await expect(page.getByRole('radio', { name: 'Express shipping' })).toBeChecked();
6
7  // Standard option should be deselected — radios are mutually exclusive
8  await expect(page.getByRole('radio', { name: 'Standard shipping' })).not.toBeChecked();
9});
#radio#check#getByRole#exclusive