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 DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

How to Fix Selenium Buttons That Do Not Work in Headless Mode

A failed Selenium click in headless mode can point to timing, a stale or wrong element, an overlay, or browser setup. Diagnose the exception and verify the page state after clicking.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Selenium button that fails only in headless mode usually needs a diagnosis, not a special click command. Start with the exception: it points toward a missing or stale element, an obstructed click, a control that is not interactable, or a browser and driver setup problem. Then wait for the page state the action actually needs and verify what happened after the click.

Start with the exception, not a longer delay

Record the full exception and the conditions that reproduce it before changing the test. Note the Selenium binding and version, browser and driver versions, operating system or container, headless arguments, target locator, and whether the same test succeeds in headed mode. The headed comparison is useful evidence, but it does not prove headless mode itself is the cause.

As an Amazon Associate I earn from qualifying purchases.

Selenium distinguishes missing elements, stale references, intercepted clicks, and non-interactable elements because they point to different failure modes. A page-load completion signal also does not guarantee that JavaScript-driven content is ready for the next interaction. Selenium’s troubleshooting guidance, last modified September 3, 2026, recommends identifying the underlying interaction problem rather than treating all click failures alike: Selenium WebDriver troubleshooting.

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

Use the right headless setting and compatible browser setup

Chrome with Python

Set headless mode through Chrome options. Selenium’s Chrome documentation lists --headless=new as a commonly used argument and notes that Chrome and ChromeDriver must match at the major-version level: Selenium’s Chrome documentation.

#1 Best Overall
Sale
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)

This configures Chrome to run without a visible window; it does not, by itself, fix a locator, timing, or overlay problem.

Account for Selenium’s version history

Selenium’s January 29, 2023 migration post says the headless convenience method was deprecated in Selenium 4.8.0 and removed in 4.10.0. The post describes --headless=new in the Chrome-version context of that time, including Chrome 109 and later. Treat those details as historical migration guidance, not a guarantee for every later Chrome release; check current browser and binding documentation for your installed versions: Selenium: “Headless is Going Away!”.

Rank #2
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*

For Firefox or another browser, use that browser’s own options rather than copying a Chrome flag. The code above is specifically for Chrome.

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

Wait for the state your next step needs

Navigation waiting for a document readiness state does not ensure that JavaScript assets or a single-page application’s later updates have finished. Selenium recommends condition-based explicit waits for the relevant interaction rather than fixed sleeps: Selenium waits.

Rank #3
Rii RK907 Ultra-Slim Compact USB Wired Keyboard for MAC and PC-Black(1PCS)
  • A plug-and-play USB connection with Low-profile keys give you a quiet, comfortable typing experience
  • Simple Wired USB Connection,You will enjoy a comfortable and quiet typing experience
  • The keyboard for business and office working is the budget-friendly keyboard that is built for longer use
  • Low profile keys for a more comfortable and quiet keystroke, desktop-centric design, splash resistant

Use a wait for the control to be visible and enabled, then wait for an application-specific result after clicking. Adapt this runnable pattern to a locator and success condition on your page:

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)
button = wait.until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "button[data-test='continue']"))
)
button.click()

wait.until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-test='success']"))
)

Replace both selectors with selectors that exist in the application. The second wait should represent the outcome that matters there, such as a confirmation message, dialog, selected state, or URL change. Do not mix implicit and explicit waits in the same session: Selenium warns that doing so can make timeout durations unpredictable.

Rank #4
Sale
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
  • Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
  • Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
  • Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
  • Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
  • Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable

Check that the locator identifies the intended usable control

  • Confirm the locator matches the intended button, not a hidden duplicate or a similarly named control.
  • Check that the element is visible and enabled, and that the script is in the correct window, frame, or shadow-root context where applicable.
  • If a navigation or rerender has changed the DOM, locate the element again. A stored element reference does not relocate itself after the node is detached.
  • If Selenium reports no element, check whether the script acted too early, is in the wrong context, or uses an outdated locator.

Selenium documents these distinctions in its interaction error guidance.

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

Resolve overlays and click interception

Selenium’s normal element click attempts to scroll the target into view and clicks at its center. If another element covers that point, the click can be intercepted. Sticky navigation, consent banners, modals, popups, loading layers, and animations are common things to inspect. Selenium’s element interaction behavior is described in the element interactions documentation.

  1. Inspect the screenshot or page state at the moment of failure and identify what overlaps the target.
  2. Wait for a transient loading layer, animation, or modal to disappear or settle.
  3. If the target is below a sticky header, scroll or reposition it so the clickable area is unobstructed, then retry with a condition-based wait.
  4. After the click, wait for the expected application state instead of issuing repeated clicks blindly.

A JavaScript-triggered click can bypass normal pointer hit-testing. It may hide the overlay or interactability defect that the test should catch, so use it only when the application specifically requires that behavior and document why.

Best Value
Sale
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
  • The Lenovo 300 USB keyboard offers an intuitive and comfortable island key design with 2 5 zone layout including separate number pad
  • This full-size keyboard includes concaved key caps fitted for your fingertips
  • Spill resistant keys with a board drain help keep your PC keyboard protected and keep you productive
  • The complete ergonomic design includes an adjustable tilt to improve your typing comfort
  • OS independent – This convenient computer keyboard works with laptops desktops and any computer with a USB port
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Match the symptom to the first check

Symptom What it suggests First check
NoSuchElementException The element was absent at lookup time, the locator is outdated, or the script is in the wrong context. Confirm page or frame, validate the locator, and wait for the element or preceding navigation/action.
StaleElementReferenceException The previously found node was detached or the page/context changed. Return to the correct context and locate the element again.
ElementClickInterceptedException Another element would receive the click; the target’s center may be covered. Inspect overlays, sticky bars, modals, animations, and target position; wait or reposition.
ElementNotInteractableException The target may be hidden, disabled, outside the viewport, or not the intended control. Verify the locator and element state; wait for usability and scroll if appropriate.
Session creation or version error Browser-driver incompatibility or a configuration/executable problem. Check browser and driver major versions and the browser’s setup details.

These exception categories and first checks follow Selenium’s troubleshooting guidance; the precise underlying cause still depends on the page and environment.

Or skip the browser setup

If the task is to capture a page rather than test a button interaction, ScreenshotNeo returns a screenshot or PDF from one GET request. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. It also provides an MCP server for AI agents, including Claude, Cursor, and other MCP clients.

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

Example cURL request (replace the URL with the page to capture):

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

See the ScreenshotNeo API documentation for request options. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for the free plan.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 2
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.39
Bestseller No. 3
Rii RK907 Ultra-Slim Compact USB Wired Keyboard for MAC and PC-Black(1PCS)
Rii RK907 Ultra-Slim Compact USB Wired Keyboard for MAC and PC-Black(1PCS)
Simple Wired USB Connection,You will enjoy a comfortable and quiet typing experience
$9.99
SaleBestseller No. 4
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
Product carbon footprint: 5.03 kg CO2e
$17.77
SaleBestseller No. 5
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
This full-size keyboard includes concaved key caps fitted for your fingertips; The complete ergonomic design includes an adjustable tilt to improve your typing comfort
$13.39

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.

Leave a Reply

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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.