elements / select

Single UI element

Select

A native single select, a multi-select, and a dependent cascading country → city dropdown pair.

Single select

#select-single
id
select-single
default
medium
expected
Only one option selectable at a time.
Code snippets
Python (Selenium)
from selenium.webdriver.support.ui import Select

sel = Select(driver.find_element(By.ID, "select-single"))
sel.select_by_value("urgent")
assert sel.first_selected_option.text == "Urgent"
TypeScript (Playwright)
await page.selectOption('#select-single', 'urgent');
expect(await page.inputValue('#select-single')).toBe('urgent');

Multi-select

#select-multi
id
select-multi
expected
Supports multiple selected options simultaneously.
Code snippets
Python (Selenium)
from selenium.webdriver.support.ui import Select

sel = Select(driver.find_element(By.ID, "select-multi"))
sel.deselect_all()
sel.select_by_value("bug")
sel.select_by_value("p1")
vals = [o.get_attribute("value") for o in sel.all_selected_options]
assert "bug" in vals and "p1" in vals
TypeScript (Playwright)
await page.selectOption('#select-multi', ['bug', 'p1']);
const selected = await page.evalOnSelector(
  '#select-multi', 
  (el: HTMLSelectElement) => Array.from(el.selectedOptions).map(o => o.value)
);
expect(selected).toContain('bug');
expect(selected).toContain('p1');

Dependent dropdowns

#select-country
ids
select-country, select-city
expected
City select populates and enables only after a country is chosen.
Code snippets
Python (Selenium)
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Select(driver.find_element(By.ID, "select-country")).select_by_value("in")
city_el = driver.find_element(By.ID, "select-city")
WebDriverWait(driver, 2).until(lambda d: city_el.is_enabled())
Select(city_el).select_by_visible_text("Bengaluru")
TypeScript (Playwright)
await page.selectOption('#select-country', 'in');
await page.waitForSelector('#select-city:not([disabled])');
await page.selectOption('#select-city', { label: 'Bengaluru' });