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.

The blinking mark in a focused text field is usually the insertion caret. In a Selenium screenshot test, hide it temporarily by injecting a stylesheet immediately before capture: input, textarea, [contenteditable="true"] { caret-color: transparent !important; }. Remove that stylesheet in a finally block so the test changes do not leak into later assertions or interactions. The CSS behavior is defined by MDN’s caret-color documentation.

What you are hiding—and what you are not

An insertion caret is the vertical marker shown where text will be inserted in an editable control. It appears when an input, textarea, or editable region has focus and commonly blinks. caret-color: transparent makes that marker invisible while leaving the field’s characters, borders, background, and layout unchanged.

This is different from a mouse pointer. It is also different from a navigation caret, a browser accessibility mode that lets users move through text with the keyboard. The caret-color property targets only the insertion caret; if the reported “cursor” is another kind of pointer, this fix will have no effect. See the distinctions in MDN’s reference.

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

Inject temporary CSS in a Selenium JavaScript test

The safest pattern is to add a uniquely identified style element after navigation and page setup, take the screenshot, and remove the element regardless of whether capture succeeds. The following example uses Selenium’s JavaScript driver script execution and screenshot APIs documented for Selenium WebElement-based tests.

#1 Best Overall
Sale
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
const { Builder, By } = require('selenium-webdriver');

(async function screenshotWithoutCaret() {
  const driver = await new Builder().forBrowser('chrome').build();
  const styleId = 'selenium-hide-insertion-caret';

  try {
    await driver.get('https://example.test/form');

    // Optional page setup: focus the field or populate it before capture.
    const field = await driver.findElement(By.css('#email'));
    await field.sendKeys('[email protected]');

    await driver.executeScript((id) => {
      const oldStyle = document.getElementById(id);
      if (oldStyle) oldStyle.remove();

      const style = document.createElement('style');
      style.id = id;
      style.textContent = `
        input, textarea, [contenteditable="true"] {
          caret-color: transparent !important;
        }
      `;
      document.head.appendChild(style);
    }, styleId);

    // Selenium returns a base64-encoded PNG from takeScreenshot().
    const png = await driver.takeScreenshot();
    require('fs').writeFileSync('form-without-caret.png', png, 'base64');
  } finally {
    // Cleanup runs even when navigation, script execution, or capture fails.
    try {
      await driver.executeScript((id) => {
        document.getElementById(id)?.remove();
      }, styleId);
    } finally {
      await driver.quit();
    }
  }
})();

The style is appended only after navigation because a new document replaces the old head. If your application performs a client-side route change that reconstructs the document or replaces the relevant subtree, inject the style after that operation as well. A fixed ID makes the operation idempotent: rerunning the setup removes an earlier copy before adding a fresh one.

Use a narrower selector when appropriate

The broad selector is useful for ordinary forms, but it affects every matching editable control in the screenshot. If only one field should be changed, target it directly:

#checkout-email, #checkout-notes {
  caret-color: transparent !important;
}

[contenteditable="true"] covers the common explicit form. Some applications set contenteditable differently or make an element editable through a framework wrapper. Inspect the actual editable node and broaden the selector only when necessary. Avoid changing the production stylesheet merely to make a test image cleaner.

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

Capture timing and focus

Inject the rule after all actions that might replace the page and before the screenshot call. If a test deliberately focuses a field to verify typing, keep that focus; hiding the caret does not blur the element or alter its value. If the screenshot should show no focused control at all, blur it separately, but that is a different visual change and can affect focus-dependent styling.

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

Wait for the page state your screenshot is intended to represent before injecting the style. For example, wait for the form to render, populate asynchronous data, and finish any route transition. The CSS itself applies synchronously once the style element is in the document, so an additional animation delay is normally unnecessary for the caret.

Why disabling animation is not the same fix

Visual-testing tools sometimes expose a setting that hides insertion carets. WebdriverIO’s visual-testing methods document disableBlinkingCursor; its stated behavior is to make carets in inputs, textareas, and contenteditable elements transparent before capture and reset them afterward, and its documented default is false. That option belongs to WebdriverIO’s visual-testing API, not Selenium WebDriver. See WebdriverIO’s method options.

The same WebdriverIO documentation lists disableCSSAnimation separately. Turning off CSS animations can stabilize moving content, but it is not the specific insertion-caret fix. In a Selenium test, target the caret with CSS or implement an equivalent test-only script.

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

Other Selenium-language examples

Python

Python bindings can execute the same browser script. Ensure the cleanup runs even if save_screenshot raises an exception.

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.
from selenium import webdriver
from selenium.webdriver.common.by import By

 driver = webdriver.Chrome()
style_id = "selenium-hide-insertion-caret"
try:
    driver.get("https://example.test/form")
    driver.find_element(By.CSS_SELECTOR, "#email").send_keys("[email protected]")
    driver.execute_script("""
      const id = arguments[0];
      document.getElementById(id)?.remove();
      const style = document.createElement('style');
      style.id = id;
      style.textContent = `input, textarea, [contenteditable="true"] {
        caret-color: transparent !important;
      }`;
      document.head.appendChild(style);
    """, style_id)
    driver.save_screenshot("form-without-caret.png")
finally:
    try:
        driver.execute_script(
            "document.getElementById(arguments[0])?.remove();", style_id
        )
    finally:
        driver.quit()

Use the exact indentation and driver lifecycle conventions of your test runner; the important parts are script injection immediately before capture and unconditional removal afterward.

Java

In Java, call JavascriptExecutor.executeScript with the same stylesheet text, then use TakesScreenshot. Put removal in a finally block around the screenshot operation. The JavaScript executed in the page is identical; only the binding syntax differs.

Screenshot troubleshooting

The caret is still visible

  • Wrong element: inspect the focused node. It may be a custom editor, a shadow-DOM control, or an element with a selector not covered by the rule. Add the appropriate selector after confirming it is editable.
  • Style injected into the wrong document: a navigation or document replacement may have occurred after injection. Inject after the final navigation or route setup.
  • Another stylesheet wins: retain !important and verify in DevTools or Selenium that the computed caret-color is transparent.
  • It is not an insertion caret: a mouse pointer, text-selection highlight, or navigation caret requires a different remedy.

The text disappears or the field looks wrong

caret-color should not hide characters. Check that the injected CSS contains only the caret rule and that a selector was not accidentally given color: transparent, visibility: hidden, or an opacity rule. Remove stale style elements and rerun the test with the page’s normal stylesheet.

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.

Cleanup fails after a screenshot error

Keep cleanup nested inside finally, and make it tolerant of a missing document. If the browser has already crashed, there may be nothing left to remove; still call the driver’s quit method and let the test report the original capture failure. A unique style ID prevents duplicate rules when setup is retried.

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 screenshot is flaky despite the hidden caret

The caret may be only one source of pixel differences. Wait for the intended application state, freeze unrelated animations using a test strategy appropriate to your framework, and keep viewport, device scale, fonts, and browser versions consistent. Do not treat animation suppression as a substitute for the caret rule.

Performance, reliability, and scope

Adding one small style element is local to the current document and normally cheaper than changing the application bundle or taking a second screenshot. It does not change form values, focus, event handlers, or network requests. Its scope ends when you remove the element or navigate away.

For parallel tests, use a unique ID per browser session or a deterministic ID within each isolated document. Do not share a driver between tests that can capture concurrently. If the page uses shadow DOM, page-level CSS may not cross a shadow boundary; inject an equivalent style into the relevant shadow root only when your application permits that test instrumentation.

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

ScreenshotNeo is a website screenshot API and MCP server. For a URL-based capture, one GET request returns a PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers.

This does not replace Selenium when you need to drive a logged-in workflow, type into a field, or assert application behavior. It is useful when the desired artifact is simply a clean screenshot of a URL and you do not want to maintain browser setup. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

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.

See the complete parameter reference in the ScreenshotNeo documentation. The following calls use the supplied API format.

cURL

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

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)

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}`);

ScreenshotNeo includes full-page capture with lazy-image loading, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and margin controls, custom CSS and JavaScript, click-before-capture actions, selector hiding, waits for selectors, delays or network idle, request and resource blocking, custom headers, cookies, user agents and authorization, timezone and 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 a migration.

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

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to start with the 1,000 monthly screenshots.

Choosing between the two approaches

Need Best fit Reason
Exercise a form, authenticate, or assert behavior before capture Selenium plus temporary CSS The browser session remains under test control, and only the insertion caret is altered for the image.
Capture a public URL without maintaining WebDriver ScreenshotNeo A single request handles rendering and offers cleanup, waits, device settings, and output formats.
Use an AI agent to request screenshots or PDFs ScreenshotNeo MCP server The documented tools are available to MCP clients such as Claude and Cursor.
Already using WebdriverIO visual testing WebdriverIO’s disableBlinkingCursor It is a framework-level option documented for that visual-testing API, not a Selenium setting.

Frequently Asked Questions

Will caret-color: transparent remove the text from an input?

No. It changes the insertion marker’s color only; the field’s characters remain visible. Rules that set text color, opacity, or visibility are separate and can hide content.

Can I set the rule once in my application CSS?

You can, but test-only injection is safer because it limits the visual change to the capture and avoids altering production behavior. Remove the injected style after each screenshot.

Does WebdriverIO’s disableBlinkingCursor work in Selenium?

No. The option is documented for WebdriverIO visual-testing methods. Selenium tests should inject the CSS themselves or use another Selenium-compatible test abstraction.

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

Why does the fix not affect a cursor inside a shadow root?

Document-level CSS generally does not cross a shadow boundary. Inspect the shadow root and add equivalent test styling there only if your application and test setup allow it.

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.