SoftwareTestPilot
Inputsbeginner 8 min

Native Dropdown (Select) Element — Practice in Playwright, Selenium & Cypress

Practice dropdown select in Playwright & Selenium — selectOption, selectByVisibleText, and multi-select handling on a native <select> element.

Live element

Locators cheat-sheet

data-testidRoleAccessible labelWhat it is
country-selectcomboboxCountryNative <select> with India / US / UK options.
selected-resultstatusSelected country codeRenders the currently-selected country code.

Reference solutions

import { test, expect } from '@playwright/test';

test('selects a country and reflects the code', async ({ page }) => {
  await page.goto('/practice/dropdown-select');
  const frame = page.frameLocator('iframe[title="Dropdown live widget"]');

  await frame.getByTestId('country-select').selectOption('IN');
  await expect(frame.getByTestId('selected-result')).toHaveText('Selected: IN');

  await frame.getByTestId('country-select').selectOption({ label: 'United Kingdom' });
  await expect(frame.getByTestId('selected-result')).toHaveText('Selected: UK');
});
Try it in the Practice Hub Open learning module