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

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 identify the control. For a native HTML <select>, use Selenium .NET’s SelectElement to inspect or select options, then capture the page or element. For a JavaScript dropdown, click its trigger, wait for the rendered menu, and capture that menu or the page. Selenium documents page and element screenshots, but does not guarantee that an open native browser or operating-system popup will appear in the image.

Identify the dropdown before writing the test

Inspect the page’s DOM to determine whether the control is a native <select> or a custom component. Selenium’s SelectElement helper is specifically for HTML <select> elements; its API constructor throws UnexpectedTagNameException if the element is not a select. The helper exposes its Options and SelectedOption properties and selection methods including SelectByText, SelectByValue and SelectByIndex. See the Selenium .NET SelectElement API.

A custom dropdown may use a button, div or li elements and may render its menu only after a click. Selenium’s select-list guide says the helper “only works for HTML elements select and option”; custom overlays require normal WebDriver interactions and locators instead. See Selenium’s select-list guide.

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

Install the .NET support helper

SelectElement is in the OpenQA.Selenium.Support.UI namespace, supplied by Selenium’s Support package. In a project, use Selenium WebDriver and Selenium Support package versions compatible with the Selenium version already pinned by the project; check the API for that version before changing dependencies. The examples below assume a configured IWebDriver named driver.

Native select: inspect options or capture each selected state

When the goal is to document the available values reliably, enumerate Options. When the goal is a set of screenshots, select each choice and capture the page after any page behavior triggered by the selection has settled. This records each option as the selected state; it does not make all native options visible together.

using System.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;

IWebElement selectNode = driver.FindElement(By.Id("country"));
var select = new SelectElement(selectNode);

foreach (var option in select.Options)
{
    var text = option.Text;
    select.SelectByText(text);

    // If selection updates dependent content, wait for that content here.
    var safeName = string.Concat(text.Select(c =>
        char.IsLetterOrDigit(c) ? c : '-'));
    ((ITakesScreenshot)driver)
        .GetScreenshot()
        .SaveAsFile($"dropdown-{safeName}-{Guid.NewGuid():N}.png");
}

This example assumes the select has the stable ID country. Replace it with a locator from the actual page. The unique suffix avoids overwriting images when labels normalize to the same file name. SelectByText matches exact text by default in the .NET API; use SelectByValue when the option’s value attribute is the stable identifier, or SelectByIndex when position is specifically what the test needs. Avoid relying on an index if options can be reordered.

For a page that updates asynchronously after a selection, wait for a meaningful result—such as a changed label or dependent field—before saving. A fixed delay may be appropriate for a known animation, but an explicit wait for the expected state is generally less fragile. If the page has no dependent update, capture immediately after the selection.

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.

Can one screenshot show the native list expanded?

Do not assume so. Selenium’s documented screenshot surfaces are the page and an element; the API references do not promise that native browser or operating-system popup chrome for an expanded <select> is captured across browsers. This is an evidence limitation, not a guarantee that every browser will exclude it. If the expanded appearance is essential, verify it using the exact browser, driver and operating system used for the deliverable.

If a portable image containing every choice is required, use a controlled demonstration page that renders the choices as ordinary page content, or present one screenshot per selected value. If modifying the page, label the result as a rendered demonstration rather than a capture of the browser’s native popup.

Custom dropdown: open, wait, and capture the rendered menu

For a custom JavaScript component, locate and click the visible trigger, wait until the menu is both present and displayed, then capture the menu element or the page. The selectors below illustrate an ARIA listbox; they are not universal. Inspect the site’s DOM and accessible attributes: components may use other roles, render into a portal, use shadow DOM, or expose a different visible menu structure.

using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;

var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement trigger = wait.Until(d =>
{
    var element = d.FindElement(By.CssSelector("[aria-haspopup='listbox']"));
    return element.Displayed ? element : null;
});
trigger.Click();

IWebElement menu = wait.Until(d =>
{
    var candidate = d.FindElement(By.CssSelector("[role='listbox']"));
    return candidate.Displayed ? candidate : null;
});

menu.GetScreenshot().SaveAsFile("dropdown-options.png");

The explicit wait prevents capturing before the menu is displayed. If the click reveals options only after an animation or network request, wait for the relevant option or expected menu state as well. If the list is rendered elsewhere in the document, a page screenshot can preserve its position relative to surrounding content; a menu element screenshot is useful when the menu element itself is the desired crop. An element screenshot cannot reveal hidden content or guarantee that content clipped outside the element’s rendered bounds is included.

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.

When an overlay is inside a shadow root, locate it through Selenium’s shadow-root API rather than expecting a normal document CSS query to cross the boundary. When it is rendered in a portal, find the menu at its actual DOM location after opening the trigger. In both cases, the page’s markup determines the right locator; there is no single selector that works for every custom dropdown.

Choose the screenshot surface that matches the evidence

Selenium .NET provides a page screenshot through ITakesScreenshot.GetScreenshot() and an element screenshot through IWebElement.GetScreenshot(). The returned Screenshot can save PNG image data with SaveAsFile. See the ITakesScreenshot API and IWebElement API.

Capture the page

((ITakesScreenshot)driver)
    .GetScreenshot()
    .SaveAsFile("dropdown-page.png");

Use this when the menu’s placement, surrounding form or selected value is important. It captures the page surface Selenium documents; it does not turn hidden options into visible content.

Capture one element

menu.GetScreenshot().SaveAsFile("dropdown-menu.png");

Use this when the desired menu is a visible, locatable element and a focused image is more useful than the page context. A custom menu may have nested option elements; capturing its containing menu is usually more useful than capturing the trigger. Choose based on what the reader or test reviewer needs to see.

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

Common failures and practical fixes

  • UnexpectedTagNameException from SelectElement: The located node is not a native <select>. Inspect the DOM and use click-and-wait interactions for a custom component.
  • No options found: The locator may point to the wrong select, or the custom menu may not yet be open. Confirm the element’s tag and inspect its live DOM after the trigger action.
  • Menu capture is blank or missing: The menu may be hidden, not yet rendered, or located elsewhere (such as a portal). Wait for a displayed menu and locate the element that actually contains the visible options.
  • Screenshot shows only the trigger: Capturing the trigger does not capture a separately rendered overlay. Capture the menu or the page after opening it.
  • Native expanded options do not appear: The documented page and element APIs do not establish cross-browser capture of native popup UI. Verify the target setup, or capture each selected state or a page-rendered demonstration of the choices.
  • Images overwrite each other: Use a unique name per choice, such as an index, normalized label and unique suffix.
  • Dependent content is stale: Selection may initiate asynchronous work. Wait for the specific changed content before taking the screenshot rather than assuming the selection completed the update.
  • Element screenshot has an unexpected crop: Ensure the chosen element is the visible menu container, not a small child or trigger. Use a page screenshot if position and context matter.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot from a URL rather than a Selenium interaction test, ScreenshotNeo is a website screenshot API and MCP server for developers. A single request can return PNG, JPEG, WebP or PDF. This does not replace Selenium when you need to interact with a specific control state in an application; it is a direct capture option when a URL capture is enough.

cURL example, using the documented API call with the target URL substituted:

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

See the ScreenshotNeo documentation for the available request parameters. Cookie banners, newsletter popups and chat widgets are removed before the shot; each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits cost nothing, with page-verdict and billing details in response headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

What to verify before relying on the result

  • Confirm whether the target is a native select or a custom dropdown before choosing Selenium APIs.
  • Use the actual application’s stable locator and wait for the rendered state you intend to document.
  • Check that the saved image contains the intended evidence: all custom menu choices, a specific selected native value, or the page context.
  • If the requirement is specifically an expanded native popup, validate on the exact browser, driver and operating system rather than assuming portability from Selenium’s screenshot API.

Frequently Asked Questions

Does SelectElement work with a dropdown built from buttons or divs?

No. It is intended for native HTML select and option elements; custom dropdowns need regular WebDriver locators and interactions.

Can Selenium take a screenshot of a single selected dropdown option?

Yes. Select the option, wait for any resulting page update, and save a page or visible element screenshot.

Will a custom menu screenshot include options rendered in a portal?

It can if you locate and capture the visible menu at its actual DOM location; inspect the page structure and wait for it to appear.

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.