Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
browser automation

How to Capture Selenium Screenshots Showing Dropdown Menus in Python

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a dropdown that is visibly open, first determine whether the control is a native HTML <select> or a custom JavaScript menu. Selenium’s Select helper works only with native <select>/<option> controls. Custom menus must be opened through their trigger, followed by an explicit wait for the rendered menu, and then captured with get_screenshot_as_file().

Identify the kind of dropdown

The markup determines the correct Selenium technique. Inspect the element in browser developer tools before writing the test.

Native HTML select

A native control has a <select> element containing one or more <option> elements. Selenium’s Select class can choose an option by visible text, value, or zero-based index. That is reliable for changing the selected value in the closed control.

Choosing an option is not the same as opening the operating system’s expanded popup. The popup is rendered by the browser and operating system rather than as ordinary page HTML, so the general screenshot API does not guarantee that it will appear correctly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Custom JavaScript dropdown

Many modern interfaces use a button, div, or li as a trigger and then render a listbox or menu elsewhere in the document. Selenium’s Select helper does not apply to these overlays. Click the site’s actual trigger and wait for the menu element to become visible.

Capture a custom dropdown in Python

This is the dependable pattern for a JavaScript menu. Replace the URL and selectors with those from the page under test.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

with webdriver.Chrome() as driver:
    driver.get("https://example.com")

    # Use the page's real trigger selector.
    trigger = driver.find_element(
        By.CSS_SELECTOR, "[data-testid='dropdown-trigger']"
    )
    trigger.click()

    # Wait for the rendered menu, not merely for the click to return.
    WebDriverWait(driver, 10).until(
        EC.visibility_of_element_located(
            (By.CSS_SELECTOR, "[role='listbox']")
        )
    )

    if not driver.get_screenshot_as_file("dropdown-open.png"):
        raise RuntimeError("Selenium could not write the screenshot")

get_screenshot_as_file() saves a PNG of the current browser window. The visibility wait prevents a race in which the screenshot is taken between the click and the menu’s animation or DOM insertion.

Use a more specific trigger and menu pair

Prefer stable attributes such as data-testid, an accessible role, or a component-specific class. Avoid selectors based on generated class names that change between builds. The trigger and menu may not be adjacent: a portal can append the menu to body, so locate the visible menu globally rather than searching only inside the trigger’s parent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for animation or asynchronous content

If the menu exists immediately but fades in, wait for visibility as shown above. If its items arrive after an API request, wait for a specific option, such as [role='option'], instead of using a fixed sleep. A fixed delay is useful only when the page has no observable state to wait for; it slows every test and can still be too short on a busy run.

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere

Capture a single menu element

When the requirement is an image of the menu rather than the whole viewport, locate the visible menu and use Selenium’s element screenshot method:

menu = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "[role='listbox']"))
)
menu.screenshot("menu-only.png")

Element capture is useful for visual regression artifacts, but it excludes context such as the trigger and surrounding page. Use the window screenshot when reviewers need to see the complete interaction.

Select an option in a native control

For a real <select>, import Selenium’s helper and select the desired option before capturing the closed control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select

with webdriver.Chrome() as driver:
    driver.get("https://example.com/form")
    select_element = driver.find_element(By.ID, "country")
    country = Select(select_element)

    country.select_by_visible_text("Canada")
    # Alternatives:
    # country.select_by_value("ca")
    # country.select_by_index(2)

    driver.get_screenshot_as_file("selected-country.png")

This records the selected value in the control’s normal closed rendering. It does not promise a screenshot of the expanded native option list.

Why an expanded native popup may be missing

Selenium documents screenshots of the current browsing context and element screenshots, but the reviewed API documentation does not promise consistent capture of an expanded native-select popup across browsers and operating systems. A Selenium issue opened on April 28, 2025 (issue #15675) reports a Chrome WebDriver screenshot in which an expanded select list was offset; it was closed as not planned. That report describes one configuration, not universal behavior.

Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

If the expanded popup itself is the deliverable, test the exact browser, driver, operating system, and headed or headless mode you will use in production. Save an image and inspect it rather than assuming that selecting or clicking the control makes the popup part of the bitmap. Record the Selenium and driver versions with the artifact; the referenced Python WebDriver and Select API documentation identify Selenium 4.49.0.

Prefer a testable HTML representation when possible

If you own the application and need portable visual tests, consider exposing a custom listbox with ordinary DOM elements and accessible roles. Selenium can then click the trigger, wait for visibility_of_element_located, and capture deterministic page pixels. This changes the UI design, so do it only when it fits your accessibility and product requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Robust interaction techniques

Scroll and interact with the element

Selenium interactions can scroll an element into view and check whether it is interactable. If a sticky header or overlay blocks the click, scroll the trigger into a safe position or dismiss the blocking layer before clicking.

Use JavaScript only for diagnosis or exceptional controls

execute_script runs synchronous JavaScript in the current frame or window. It can help inspect state, for example:

state = driver.execute_script(
    "return arguments[0].getAttribute('aria-expanded');", trigger
)
print(state)

Do not replace a real user interaction with a script that merely changes a class unless your test is specifically validating that state. A synthetic class change can produce a screenshot that a user could never reach.

Handle iframes

If the dropdown is inside an iframe, switch into that frame before locating and clicking it. Capture after switching back only if your test needs the top-level page; the screenshot still represents the browser window, while element lookup is scoped to the active frame.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use

Make the viewport repeatable

Set a known window size before opening the menu so line wrapping and menu placement are comparable between runs:

driver.set_window_size(1280, 900)

Headless and headed Chrome can differ in native-popup behavior. Use the same mode in local debugging and continuous integration when the pixels matter.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

“Select only works on <select> elements”

The target is probably a custom menu. Inspect the DOM and replace Select(...) with a click on the trigger followed by a visibility wait for the menu.

The screenshot is taken before the menu appears

Wait for a state that proves the menu is rendered: a visible listbox, a visible option, or an aria-expanded="true" attribute. Increase the explicit wait timeout only after confirming that the page legitimately needs more time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The click raises an intercepted or not-interactable error

A modal, cookie layer, sticky header, or animation may be covering the trigger. Wait for the blocker to disappear, scroll the element into view, or use a selector for the underlying clickable button rather than a decorative child.

The menu is visible in the browser but absent from the image

Check that you captured the same window and frame in which the menu opened. For a custom menu, verify that the selector identifies the visible instance rather than a hidden template. For a native select popup, validate the exact browser, driver, operating system, and headless setting; portable capture is not guaranteed.

Best Value
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.

The menu is clipped

The viewport may be too short, or the component may render inside a container with overflow: hidden. Increase the viewport height, scroll the trigger, or capture the menu element itself. Changing CSS with JavaScript can be useful for a diagnostic image but may no longer represent production styling.

The PNG file is empty or not created

Check the return value of get_screenshot_as_file, use a writable absolute path, and keep the driver alive until the write completes. In parallel test runs, give each worker a unique filename.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API when you need a rendered page image without maintaining Selenium and a browser. It can click an element before capture, wait for a selector, delay, or network idle, capture a CSS-selected element, load lazy images, set a viewport or device preset, emulate dark mode, inject CSS or JavaScript, and return PNG, JPEG, WebP, or PDF. Before capture it accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled.

Only clean shots are billed. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server supplies take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients.

Use the API documentation at https://screenshotneo.com/docs/ for all parameters. A one-call example is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Equivalent Python:

import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

Equivalent Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cost, reliability, and repeatability notes

  • Selenium runs consume local CPU, memory, browser startup time, and maintenance effort, but give you direct control over clicks and application state.
  • Explicit waits based on visible state are more reliable than arbitrary sleeps.
  • Native popup screenshots require environment-specific validation; custom DOM menus are generally easier to assert and capture.
  • For remote capture, ScreenshotNeo’s verdict and billing headers let you distinguish a clean billed shot from a failed or non-billed response, while a chosen cache TTL can reduce repeat work.

Frequently Asked Questions

Can I use Selenium’s Select class on a div-based dropdown?

No. Select is intended for native select and option elements; click and wait for the custom component instead.

Does selecting an option guarantee that the expanded native list appears in the screenshot?

No. Selection changes the control’s value, while the expanded popup is browser- and operating-system-rendered and must be validated in the exact target environment.

Should I use a fixed sleep after clicking the trigger?

Prefer an explicit wait for a visible menu or option. Use a fixed delay only when no observable readiness condition exists.

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
SaleBestseller No. 3
Bestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.