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 whether the dropdown is a native HTML <select> or a custom widget. For a native select, use Selenium’s Select helper, save the option labels or values before the loop, and find the select again after each selection if the page rerenders. For a custom menu, open it and click its visible options with ordinary Selenium locators. In both cases, wait for the page state that confirms each selection has finished before continuing.
Identify the dropdown before choosing an approach
The visual appearance of a dropdown does not tell you which Selenium API to use. Inspect the element in the browser’s developer tools or examine its tag in Selenium. A native dropdown is an actual HTML <select> containing <option> elements. A custom dropdown is usually composed of buttons, divs, list items, or elements with ARIA roles such as combobox and option.
element = driver.find_element(By.ID, "country")
print(element.tag_name)
If the tag name is select, Selenium’s Select helper is appropriate. If it is a button, div, or another element, use ordinary locators and clicks. Trying to pass a custom widget to Select will not work as intended.
Loop through a native select safely
For a standard select, collect stable values before the loop. This creates a snapshot rather than iterating over live WebElements that may become invalid if the page updates. The example below selects every non-empty option value. It assumes that the selection causes the old select element to be replaced; if the page does not rerender it, replace the staleness wait with a condition that reflects the page’s actual response.
#1 Best Overall
- FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
- AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
- ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
- AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
- STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Assumes driver is already configured and the target page is open.
wait = WebDriverWait(driver, 10)
select_locator = (By.ID, "country")
select_element = wait.until(EC.presence_of_element_located(select_locator))
option_values = [
option.get_attribute("value")
for option in Select(select_element).options
if option.get_attribute("value")
]
for value in option_values:
# Re-find the select on each pass; do not reuse an old WebElement.
select_element = wait.until(EC.element_to_be_clickable(select_locator))
Select(select_element).select_by_value(value)
# Keep this only when selection replaces the select in the DOM.
wait.until(EC.staleness_of(select_element))
The timeout value is an example, not a guarantee that every page will be ready within that period. The important part is to wait for a meaningful condition rather than to assume that a fixed pause is long enough.
Choose values, visible text, or an index
Selenium’s Python Select supports choosing an option by its value, its visible text, or its zero-based index. Prefer values or visible labels where possible: indexes can become wrong if the site inserts, removes, or reorders options.
select_by_value(value)targets the option’s HTMLvalueattribute.select_by_visible_text(label)targets the text shown to the user.select_by_index(index)targets an option’s position, starting at zero.
For example, if the select contains a placeholder such as “Choose a country,” decide whether that placeholder belongs in the loop. Filtering out empty values is useful only when empty values identify options you do not want; sites may use meaningful values that happen to be empty, so inspect the markup and adapt the filter.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #2
- Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
- 14" HD Display: 14.0-inch diagonal, HD (1366 x 768), micro-edge, anti-glare. See your digital world in a whole new way. Enjoy movies and photos with the great image quality and high-definition detail of 1 million pixels.
- Memory & Storage: 4 GB LPDDR4x & 64 GB eMMC Storage. Adequate high-bandwidth RAM to smoothly run multiple applications and browser tabs all at once. An embedded multimedia card provides reliable flash-based storage.
- Ports:2 x USB 3.0 Type-A,1 x USB 3.0 Type-C,1 x HDMI,1 x Headphone Jack
- Chrome OS: Chromebook is a computer for the way the modern world works, with thousands of apps. Enjoy the seamless simplicity that comes with Google Chrome and Android apps, all integrated into one laptop. It’s fast, simple, and secure.
Wait for the result, not just the selection command
A successful select_by_* call does not necessarily mean that the site’s dependent content has finished updating. If changing a country loads regions asynchronously, wait for the region list or another result to change before selecting the next country. Suitable signals include a known result text, a URL change, an old result element becoming stale, or a new element appearing.
from selenium.webdriver.support import expected_conditions as EC
result_locator = (By.ID, "selected-country")
for value in option_values:
select_element = wait.until(EC.element_to_be_clickable(select_locator))
Select(select_element).select_by_value(value)
wait.until(EC.text_to_be_present_in_element(result_locator, value))
Use the condition that actually describes your page. A text condition is appropriate only if the displayed result contains the selected value. A staleness condition is appropriate only if that particular element is replaced. If the page updates an element in place, wait for its text or another observable state instead.
Click each native option only when a click is required
Most tests should use Select.select_by_visible_text or another selection method for a native select. This communicates the intended operation directly and avoids unnecessary locator work. If the test specifically needs a click on the <option> element, snapshot labels first and locate each option again during the loop.
Rank #3
- Stunning 15.6" FHD IPS Display: Experience crisp 1920x1080 resolution on this 15.6 inch laptop with an IPS panel that delivers wide viewing angles and vivid colors. The narrow-bezel design maximizes screen real estate for comfortable viewing on this Win 11 laptop, whether you're studying or working.
- Celeron J4105 Processor & 256GB SSD: Powered by a reliable Celeron J4105 processor paired with 12GB DDR4 memory and a fast 256GB M.2 SSD. This laptop computer supports SSD expansion up to 2TB and TF card expansion up to 1TB, so your storage grows with your needs. Delivers smooth multitasking for daily productivity.
- AI-Powered Win 11 Laptop: Built-in AI features enhance your productivity with smart assistance for writing, summarizing, and task management. Pre-installed with Win 11 and includes Office 365 subscription. This student laptop is backed by 1-year warranty and 24/7 customer support.
- All-Day 7000mAh Battery & 180° Hinge: The high-capacity 7000mAh battery keeps this laptop powered through long classes or meetings. The 180-degree lay-flat hinge lets you share your screen effortlessly during presentations. This durable laptop computer adapts to your dynamic workflow.
- Versatile Connectivity Hub: Equipped with USB 3.2, Type-C, Mini HDMI, and 3.5mm audio jack to connect all your peripherals. Stay online anywhere with high-speed 5G WiFi and Bluetooth 4.2. This college laptop keeps you connected at home, in the library, or on the go.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
select_locator = (By.ID, "country")
select_element = wait.until(EC.presence_of_element_located(select_locator))
option_labels = [
option.text
for option in Select(select_element).options
if option.text.strip() and option.get_attribute("value")
]
for label in option_labels:
select_element = wait.until(EC.presence_of_element_located(select_locator))
options = select_element.find_elements(By.TAG_NAME, "option")
option = next((item for item in options if item.text.strip() == label), None)
if option is None:
raise RuntimeError(f"Option disappeared: {label!r}")
option.click()
# Add a page-specific wait here if selecting triggers an update.
This version compares text in Python rather than inserting label text into an XPath expression. That avoids quoting and escaping problems, particularly when labels contain apostrophes or other special characters. Do not retain the located option for a later iteration: a page refresh or rerender can make it stale.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteLoop through a custom dropdown
A custom dropdown requires the same interactions a user would perform: wait for its toggle, open the menu, wait for the target option to be clickable, click it, and wait for evidence that the selection took effect. The locator attributes below are examples; replace them with attributes present on the page you are automating.
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
toggle = (By.CSS_SELECTOR, "[data-testid='country-menu']")
selected_country = (By.ID, "selected-country")
values = ["CA", "GB", "US"]
for value in values:
wait.until(EC.element_to_be_clickable(toggle)).click()
option = (By.CSS_SELECTOR, f"[role='option'][data-value='{value}']")
wait.until(EC.element_to_be_clickable(option)).click()
wait.until(EC.text_to_be_present_in_element(selected_country, value))
For custom widgets, the option may only exist in the DOM after opening the menu. Locate it after opening, not before. If selecting an item closes the menu, reopen it on every iteration as in the example. If the widget uses a different attribute or its displayed selection is not the raw value, adapt both the locator and the completion condition.
Rank #4
- Efficient Performance for Everyday Computing: Powered by Intel N150 processor with up to 3.6 GHz Intel Turbo Boost Technology, 6 MB L3 cache, 4 cores, and 4 threads, this HP laptop delivers responsive performance for web browsing, streaming, document editing, and multitasking. Paired with 4GB LPDDR5 RAM and 128GB UFS storage, it handles daily tasks smoothly. Includes 1-year Microsoft 365 Personal subscription for Word, Excel, PowerPoint, and cloud storage to maximize your productivity.
- 14-Inch HD Micro-Edge Display:Enjoy clear visuals on the 14-inch HD (1366 x 768) anti-glare screen with 250-nit brightness and 62.5% sRGB coverage. The micro-edge bezel delivers a 79% screen-to-body ratio in a compact design. An HP True Vision 720p HD camera with noise reduction and dual-array microphones supports clear video calls, remote work, and online learning.
- Modern Connectivity and Wireless Technology: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.4 for seamless pairing with accessories. Versatile port selection includes 1 USB Type-C 10Gbps with DisplayPort 1.2 for external displays, 2 USB Type-A 5Gbps ports for peripherals, 1 HDMI 1.4b port, 1 headphone/microphone combo jack, and 1 multi-format SD media card reader. Connect monitors, transfer files quickly, and expand your workspace with ease.
- All-Day Battery Life and Portable Design: Enjoy up to 11 hours of video playback, 7.5 hours of mixed usage, or 7.5 hours of wireless streaming on a single charge, perfect for students and professionals on the go. Weighing just 3.24 lb and measuring 12.76" x 8.86" x 0.71", this lightweight laptop fits easily in backpacks and bags. The stylish willow green top cover with matte finish and natural silver keyboard deck with vertical brushing pattern offer a modern, professional look.
- AI-Enhanced Productivity: Access Microsoft Copilot instantly with the dedicated Copilot key for faster assistance. AI Noise Reduction filters background sounds and improves voice clarity during calls. Dual speakers provide clear audio, while the full-size natural silver keyboard and HP Imagepad support comfortable typing and navigation.
Prefer stable, semantic locators
Use an ID, name, data-* attribute, or relevant ARIA role when the page provides one. A selector such as [role='option'][data-value='CA'] expresses what the target is. A positional XPath such as “the third div under the menu” is fragile: filtering, hidden entries, or virtualization can change positions.
Some custom menus render only the visible options. If the list is virtualized, a snapshot of every option may not exist in the DOM at once. In that case, interact with the currently rendered choices and the widget’s scrolling or search behavior; do not assume that finding the first visible option elements represents the entire dataset.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose between selection and clicking
| Approach | Use it when | Important consideration |
|---|---|---|
Select.select_by_* |
The control is a native <select> and the goal is to set an option. |
Wait separately for any asynchronous page response. |
Click a native <option> |
The test specifically requires an option click. | Re-find the select and option after each update. |
| Click custom menu items | The control is built from ordinary elements rather than a native select. | Open the menu for each pass and locate a visible option using stable attributes. |
The decision turns on the control type, whether selection rerenders the page, whether a real click is part of the test requirement, and how the completion state can be observed. A helper call is not a substitute for waiting for the resulting page behavior.
Best Value
- 【Expansive Display】The 14 Non-touch display offers clear and vibrant visuals, and anti-glare coating, perfect for both work and entertainment.
- Designed for mobility with a slim 0.71-inch profile and lightweight 3.24 lb chassis, making it easy to carry between home, office, school
- 【Versatile Connectivity】Stay connected with multiple ports including USB 3.0 Type-C, USB 3.0 Type-A, HDMI, and a headphone/mic combo jack, along with Wi-Fi and Bluetooth for seamless wireless networking.
- One Year Microsoft 365
Common loop errors and fixes
StaleElementReferenceException: The page replaced the select or option after a selection. Keep only strings such as labels or values between passes, then locate the element again inside the loop.ElementClickInterceptedException: An overlay, modal, sticky header, or animation is covering the target. Wait for the obstruction to disappear and for the element to be clickable. Scroll into view only if positioning is the issue.NoSuchElementException: The menu or option is not yet present, the locator is inaccurate, or the code is treating a custom widget as a native select. Inspect the rendered markup and wait for presence when the element loads asynchronously.TimeoutException: The requested wait condition never became true. Confirm that the condition matches the page’s real completion signal before increasing the timeout. An arbitrary sleep can make a slow case appear to work while still failing unpredictably.- The click succeeds but the next result is wrong: The page may be updating asynchronously. Wait for a result element, text change, URL change, or relevant staleness before starting another iteration.
- The loop misses options: Check whether the options are filtered, inserted after opening the menu, or virtualized. A one-time list of currently rendered elements may not contain every possible choice.
Or skip the browser setup
If your goal is to capture the page after automating it—or you only need a screenshot or PDF rather than Selenium interaction—ScreenshotNeo is a website screenshot API and MCP server. It does not click through dropdowns or replace Selenium for interaction tests; it can capture a URL directly.
For example, this cURL request captures a page as WebP. 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
ScreenshotNeo removes supported cookie and consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
PC 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 & 11Crashes, 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 minuteSign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Does Select.select_by_visible_text() return the selected option?
No. It performs the selection and returns no option object. If you need to inspect an option element, locate it separately.
Can Selenium click a native <option> directly?
Selenium Python navigation guidance documents clicking options, but for ordinary selection of a native control the Select helper is generally clearer.
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.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →

