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

To capture a Selenium screenshot that includes a tooltip, move the pointer onto the tooltip’s trigger, wait until the rendered tooltip is visible, and save the screenshot without moving the pointer away. In Python, ActionChains(driver).move_to_element(trigger).perform() performs the hover, an explicit wait handles animation or JavaScript rendering, and driver.save_screenshot("tooltip-visible.png") captures the current window.

The reliable hover-and-capture sequence

A tooltip is usually shown only while its trigger is hovered. The screenshot must therefore be taken in the same browser state as a real user hover. The dependable order is:

  1. Locate the element that opens the tooltip.
  2. Move the virtual pointer onto that element.
  3. Wait for the tooltip overlay or its text to become visible.
  4. Save the screenshot while the pointer remains over the trigger.

Waiting for the trigger to exist is not enough. A trigger can be present in the DOM while the tooltip is still hidden, transitioning, or being created elsewhere in the document.

Complete Python example

The following example uses an application-rendered tooltip. Replace the trigger and tooltip selectors with those used by your page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = webdriver.ChromeOptions()
# options.add_argument("--headless=new")  # Enable when running headlessly.
driver = webdriver.Chrome(options=options)
wait = WebDriverWait(driver, 10)

try:
    driver.set_window_size(1440, 1000)
    driver.get("https://example.com/page-with-tooltip")

    trigger = wait.until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "[data-tooltip]"))
    )
    driver.execute_script(
        "arguments[0].scrollIntoView({block: 'center', inline: 'center'});",
        trigger,
    )

    ActionChains(driver).move_to_element(trigger).perform()

    # Use the selector generated by your component library.
    tooltip = wait.until(
        EC.visibility_of_element_located(
            (By.CSS_SELECTOR, ".tooltip, [role='tooltip']")
        )
    )

    # The pointer stays on trigger while this call completes.
    if not driver.save_screenshot("tooltip-visible.png"):
        raise IOError("Selenium could not write tooltip-visible.png")
finally:
    driver.quit()

save_screenshot(filename) saves the current window as a PNG and returns False when Selenium encounters an I/O error. Selenium also provides get_screenshot_as_file (a filename ending in .png is required), get_screenshot_as_png for raw bytes, and get_screenshot_as_base64 for embeddable Base64 data.

Choosing the correct tooltip locator

Stable trigger selectors

Prefer an ID, a dedicated data attribute, or a semantic CSS selector over a long XPath tied to layout. Examples include By.ID("help-icon"), By.CSS_SELECTOR("[data-tooltip='billing']"), and an XPath that targets an accessible label. A stable trigger makes the test less sensitive to redesigns.

Generated tooltip selectors

Many libraries render an overlay near the end of <body> rather than inside the trigger’s parent. Inspect the DOM after hovering and identify the generated node. Common hooks are role="tooltip", a library-specific class, or an ID referenced by aria-describedby. Wait for that overlay globally; searching only inside the trigger can fail when the tooltip is rendered in a portal.

Waiting for text instead of a class

If the class is transient, wait for the expected text:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tooltip = wait.until(
    EC.visibility_of_element_located((By.XPATH, "//*[contains(normalize-space(), '税')]"))
)

For maintainable tests, use a narrower selector than a page-wide text search, and verify that the matched node is displayed.

CSS hover, JavaScript overlays, and native bubbles

CSS :hover tooltips

These depend directly on pointer position. Do not click another element, move to the tooltip, or perform a second action before the screenshot. If the tooltip itself is not inside the hover region, moving toward it can hide it.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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

JavaScript-triggered overlays

JavaScript components may add a node after a delay, animate opacity, or require focus as well as hover. Use an explicit visibility wait rather than a fixed sleep. If the component has a documented open event or state attribute, waiting for that state is often more deterministic than waiting for a delay.

Native browser title bubbles

A native bubble produced only by an element’s title attribute may not be page content that WebDriver can include in a screenshot. Test the accessible title or ARIA value separately, or change the application to render an HTML tooltip when pixel evidence is required.

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.

Viewport, scrolling, and screenshot scope

Preventing clipping

Set a deterministic window size and scroll the trigger to the center before hovering. A tooltip can be clipped at the top or bottom of the viewport even though its text is visible in the DOM. If the application positions overlays differently at breakpoints, use the same viewport in every run.

Window versus element screenshots

driver.save_screenshot captures the current browser window, including surrounding context. An element screenshot can be useful for a focused assertion, but an overlay rendered outside the element’s box may be omitted. Choose a window capture when the tooltip’s placement relative to the trigger matters.

Full-page expectations

A normal WebDriver screenshot is a viewport image, not automatically a stitched full-page capture. If the tooltip appears only in one viewport, capture that viewport after scrolling. Stitching or browser-specific full-page features can change hover state and should be validated separately.

Making the capture deterministic

Use explicit waits

Wait for visibility, not merely presence. Visibility checks that the element has a rendered size and is displayed. For text that changes after opening, add a condition for the expected text or an attribute indicating the open state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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.

Control animations

Animations can make screenshots vary from run to run. When your application permits it, inject test CSS that disables transitions, or wait for the final state exposed by the component. Keep the pointer stationary until the image has been written.

Use a fresh browser state

Cookie consent dialogs, onboarding prompts, and other overlays can cover the trigger. Dismiss them before hovering, or configure a clean test profile. A blocked trigger can cause Selenium to move to a nearby coordinate without opening the tooltip.

Capture bytes when you need custom storage

png_bytes = driver.get_screenshot_as_png()
with open("tooltip-visible.png", "wb") as image_file:
    image_file.write(png_bytes)

This approach lets a test attach the bytes to a report or upload them to object storage without a temporary browser-side file.

Troubleshooting missing tooltip text

The screenshot is taken too early

Symptom: The trigger is visible but no tooltip appears. Fix: wait for the tooltip overlay’s visibility or expected text after move_to_element(...).perform(). Increase the explicit wait only after confirming the selector is correct.

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

The tooltip disappears before saving

Symptom: It flashes during debugging but is absent in the file. Fix: remove actions between the hover and screenshot, and do not move the pointer to inspect the overlay. CSS hover state must remain active until save_screenshot returns.

You waited for the wrong node

Symptom: The wait times out although the tooltip is visible. Fix: inspect the post-hover DOM. The component may use a portal, a generated class, or an iframe. Update the locator to the actual rendered overlay and switch into the correct iframe before locating it when necessary.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

The trigger is outside the viewport

Symptom: The pointer action runs but nothing opens, or the tooltip is cut off. Fix: scroll the trigger into view, center it, and use a known window size. Check for a sticky header covering the target.

An overlay intercepts the pointer

Symptom: Selenium reports that the element is not clickable or the hover has no effect. Fix: close consent, chat, or modal layers; wait for them to become invisible; then perform the hover. Avoid JavaScript-only pointer simulation unless the component is explicitly designed to respond to it, because it may not reproduce real pointer behavior.

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

The tooltip is a native title bubble

Symptom: The text exists in title, but no HTML tooltip node appears. Fix: assert the attribute or accessible description. For a screenshot, ask the application to expose a rendered tooltip component.

The file is empty or missing

Symptom: The test reports success but no usable image exists. Fix: check the Boolean return value, use an absolute writable path, and ensure the filename ends in .png when using file-based APIs. Preserve the image as a test artifact so a failed run can be inspected.

Performance and reliability considerations

Explicit waits normally finish as soon as the condition is met, while fixed sleeps always consume their full duration and still risk races. Keep the timeout long enough for the slowest supported environment, but fail with a diagnostic message when it expires. A deterministic viewport, stable selectors, disabled test animations, and a clean profile reduce flaky captures more effectively than repeatedly increasing sleep times.

Hover behavior can differ between headed and headless runs, browser versions, operating systems, and device-pixel ratios. Run the same browser configuration in local and CI environments when pixel comparison matters. Store the browser, driver, viewport, URL, and tooltip selector with the artifact so a mismatch can be reproduced.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

When you only need a clean page image rather than an interaction-specific hover state, ScreenshotNeo provides a website screenshot API and MCP server. Its capture pipeline accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.

For a straightforward page capture, use the API shown in the ScreenshotNeo documentation:

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

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

And in 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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo supports full-page captures with lazy images loaded, CSS-selector element shots, dark mode, 12 device presets plus custom viewports, retina scale, PDF output, custom CSS and JavaScript, pre-capture clicks, selector waits, delay or network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients, so an AI agent can request captures without you building browser orchestration. The Free plan includes 1,000 screenshots per 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.

When Selenium remains the right choice

Use Selenium when the tooltip itself is the subject of the test: you need to hover a particular control, verify its text, reproduce keyboard or pointer behavior, or capture the exact interactive state. Use an HTTP screenshot service for repeatable page renders, bulk URLs, PDFs, or agent-driven captures where no hover interaction is required. For a tooltip-specific screenshot, Selenium’s pointer action plus an explicit visibility wait remains the essential pattern.

Frequently Asked Questions

Can I use a fixed sleep instead of an explicit wait?

You can, but a fixed sleep is slower and can still race with a slow render. Wait for the tooltip overlay or expected text so the capture proceeds as soon as the rendered state is ready.

Why does moving the pointer to the tooltip hide it?

The tooltip may be controlled by CSS :hover on the trigger. Moving away ends that state. Save the screenshot while the pointer remains on the trigger.

Will Selenium capture a browser-native title tooltip?

Not reliably. A native title bubble may not be page content available to WebDriver screenshots. Assert the title or ARIA value, or render an HTML tooltip for visual capture.

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

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.