Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
First check the page’s markup. If the control is a native HTML <select>, wrap it with Selenium’s Select helper and choose an option by its visible text, value, or index. If it is a custom JavaScript dropdown built from elements such as div or li, use ordinary WebDriver locators and interactions instead: Selenium’s Select helper is only for native select lists. Selenium’s select-list guide documents that distinction and the supported selection methods.
Identify what kind of dropdown the page uses
A control that looks like a dropdown is not necessarily an HTML <select>. The distinction determines the Selenium technique, so inspect the rendered page’s markup or the application’s DOM before writing the interaction.
Native select list
A native control has a <select> element containing <option> elements. Use Selenium’s language-specific Select helper on the <select> element. The helper provides methods for selecting by label, option value, and index, as well as methods for multi-select controls. See the official select-list documentation.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Custom JavaScript dropdown
A custom widget may use a button, div, li, or another element to show and choose options. It may resemble a select list visually, but it is not a native <select>, so constructing Selenium’s Select helper for it will not work. Locate and interact with its trigger and option elements using regular WebDriver element interactions. Selenium’s guides cover locator strategies and element interactions.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Select an option from a native dropdown in Python
Install the Selenium library for your language and make sure your browser and WebDriver setup are ready. Selenium’s official installation guide lists the language libraries and installation steps. The following Python example opens your application, waits for a native select list, chooses an option by its visible label, and checks that Selenium reports the intended option as selected.
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select, WebDriverWait
app_url = os.environ["APP_URL"]
# Replace this locator and label with the ones used by your page.
select_locator = (By.ID, "country")
option_label = "Canada"
with webdriver.Chrome() as driver:
driver.get(app_url)
wait = WebDriverWait(driver, 10)
select_element = wait.until(
lambda browser: browser.find_element(*select_locator)
)
country = Select(select_element)
country.select_by_visible_text(option_label)
selected_option = country.first_selected_option
assert selected_option.text.strip() == option_label
Set APP_URL to the page under test, then replace (By.ID, "country") and "Canada" with a locator and label from that page. The wait here is for the select element to exist; if your application renders the control asynchronously, this avoids immediately attempting to locate an element that has not appeared yet. If the page replaces or updates the control after loading, wait for the relevant state before interacting with it.
Choose the right option-matching method
Use the form of identification that best expresses the choice your test intends to make. Selenium’s select helper exposes three approaches:
| Method | What it matches | Use it when |
|---|---|---|
select_by_visible_text("Canada") |
The option’s displayed label | The user-facing label is the clearest expression of the choice. |
select_by_value("ca") |
The option’s value attribute |
The page’s option value is the identifier your test needs. |
select_by_index(2) |
The option’s position in the list | The position itself is intentional and stable for the test. |
For example, if the markup contains <option value="ca">Canada</option>, choose either the visible label or the value according to what the test is meant to verify:
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
country.select_by_visible_text("Canada")
# Or, when the option value is the intended identifier:
country.select_by_value("ca")
Text and value usually make the intent easier to understand than a bare index. An index identifies position, so changing the order of the options can make the same index point to a different choice. Selenium’s examples include selectByVisibleText("Four"), selectByValue("two"), and selectByIndex(3); method naming varies by language binding. Consult the select-list guide for the binding you use.
Handle a select list that allows multiple choices
A native list supports multiple selections only when its <select> element has the HTML multiple attribute. Check the page’s markup rather than inferring multi-select behavior from how the widget looks. With a multiple select, select each desired option and inspect the resulting selected options.
from selenium.webdriver.support.ui import Select
interests = Select(driver.find_element(By.ID, "interests"))
assert interests.is_multiple
interests.select_by_visible_text("Technology")
interests.select_by_value("design")
chosen = {
option.text.strip()
for option in interests.all_selected_options
}
assert chosen == {"Technology", "Design"}
Replace the locator and expected labels with values from the application. The is_multiple check makes the test fail clearly if the page no longer exposes a multi-select control. To clear choices, the helper also provides deselection methods for multiple selects, including clearing all selected options. Those deselection methods do not apply to a single-choice select.
Work with a custom JavaScript dropdown
For a custom widget, use its real trigger and option elements rather than passing the trigger to Select. A common interaction is to click the trigger, wait until the intended option is available, click it, and then verify the page’s resulting state.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait(driver, 10)
# Replace these example locators with the widget's actual DOM locators.
trigger = wait.until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "[data-test='region-trigger']"))
)
trigger.click()
option = wait.until(
EC.element_to_be_clickable((By.XPATH, "//li[normalize-space()='Canada']"))
)
option.click()
# Assert against the widget's displayed selection or another meaningful result.
selected_label = wait.until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, "[data-test='region-value']")
)
)
assert selected_label.text.strip() == "Canada"
The selectors in this example are illustrative, not universal Selenium selectors: inspect your application and choose locators that match its markup. The option may not be present in the DOM until the trigger is opened, and the widget may update its selected label asynchronously. Waiting for the option and then for the displayed result makes the test check the page’s response instead of treating a click as proof of success.
WebDriver element interactions include commands such as clicking and sending keys. The Selenium documentation notes that ordinary interactions attempt to scroll an off-screen element into view and ensure it is interactable, but a custom widget can still have application-specific behavior that your test must wait for or assert. See interacting with web elements and locator strategies.
Wait for and verify the selection
A selection command and a successful test assertion are different things. After choosing an option, verify the state that matters to the test: the selected option, the widget’s displayed value, or a dependent page update. This catches cases where an interaction did not take effect or the page has not finished updating.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Wait for a native option to become selected
In Python, Selenium’s expected conditions include a wait for an element to be selected and a wait for a specified selection state. For a native option, one form is:
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
option_locator = (By.CSS_SELECTOR, "#country option[value='ca']")
WebDriverWait(driver, 10).until(EC.element_located_to_be_selected(option_locator))
Use a locator that identifies the option in your page. The Python API documents selection-related expected conditions at selenium.webdriver.support.expected_conditions. For a custom dropdown, choose a condition tied to its actual result—for example, the selected label becoming visible or the expected option gaining the state represented in the widget’s markup.
Disabled controls and options
Check enabled state when a selection fails unexpectedly. Selenium’s select-list documentation states that, since Selenium 4.5, a Select object cannot be created for a disabled <select>; it also notes that options carrying disabled may not be selected. These details are version-sensitive; see the current Selenium select-list documentation for the behavior described there.
If the application enables the control only after another action, wait for the select to become available before constructing or using the helper. If a particular option is disabled, the test should reflect the page’s intended behavior rather than treating the option as selectable. Do not work around disabled state by targeting hidden or unrelated markup: assert the user-visible behavior your test is meant to cover.
Common dropdown failures and fixes
| Symptom | Likely cause | What to check or change |
|---|---|---|
The Select helper rejects the element. |
The located element is a custom widget element, not a native <select>. |
Inspect the markup. For a custom control, locate and interact with its trigger and option elements instead. |
| The option cannot be selected. | The option may be disabled, the locator may identify the wrong option, or the control may not be ready. | Check the option’s value, visible label, and enabled state; wait for the relevant control or option before acting. |
| The test selects the wrong choice after a page change. | The test relies on an index, and option ordering changed. | Prefer a label or value when that more directly identifies the intended choice. |
| A click runs but the custom widget does not show the new choice. | The option may not yet be visible or interactable, or the application may update asynchronously. | Wait for the option before clicking, then wait for and assert the resulting selected state. |
| A multi-select test fails while deselecting. | The element is not a multiple select. | Confirm that the native <select> has the multiple attribute; deselection methods are for multiple selects. |
Keep dropdown tests reliable and efficient
- Use a locator that expresses the target. A stable identifier for the control or option is easier to maintain than a selector tied to incidental layout. Selenium’s locator guide describes the available strategies.
- Wait for the condition you need. A fixed delay does not establish that a control or selection is ready. Prefer a wait for the element, option, or resulting state that matters.
- Assert the outcome. Check the selected option or a meaningful page response rather than stopping after the selection command.
- Avoid repeated retries without diagnosis. First determine whether the control is native or custom, whether the element is enabled, and whether the intended option can be located. Repeatedly issuing the same interaction will not repair a mismatched control type or locator.
For test cost and runtime, the practical work is in starting and controlling the browser, waiting for the application’s actual state, and keeping locators aligned with the page. The supplied Selenium documentation does not establish a universal timing or performance figure for dropdown interactions; execution time depends on the application, browser, and test setup.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Or skip the browser setup
ScreenshotNeo is a website screenshot API, not a Selenium dropdown-selection tool, so it does not replace the interaction code above. It can be useful when you need a screenshot of a page for visual debugging or records. One GET request returns a screenshot or PDF; see the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
With ScreenshotNeo, cookie banners and consent overlays are accepted and removed before capture, along with supported newsletter popups and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools for taking screenshots, getting page information, and capturing PDFs. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Can I use Selenium to select an item from a dropdown in an iframe?
The material cited here does not cover iframe handling. Check Selenium’s documentation for frame switching before applying the native-select or custom-widget interaction to an element inside a frame.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsDoes the Selenium Select helper support a dropdown built with div elements?
No. It is specifically for native HTML select lists. A div-based control needs normal WebDriver locators and interactions.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

