// Select by label, value, or index
await page.selectOption('#country', 'India'); // by label
await page.selectOption('#country', { value: 'IN' }); // by value
await page.selectOption('#country', { index: 2 }); // by index
// Multi-select
await page.selectOption('#hobbies', ['Reading', 'Music']);
Radio Buttons & Checkboxes
// Radio: just click the label or input
await page.getByLabel('Male').check();
// Checkbox
await page.getByRole('checkbox', { name: 'Agree' }).check();
await expect(page.getByRole('checkbox', { name: 'Agree' })).toBeChecked();
// Toggle
await page.getByLabel('Subscribe').uncheck();
// Open a new tab in the same context
const page2 = await context.newPage();
await page2.goto('https://example.com');
// Switch between tabs
await page.bringToFront();
await page2.bringToFront();
✏️ Exercise: Write a test that opens a form with dropdown, radio buttons, and checkboxes. Select values, submit, and assert the success message appears.