Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › browser automation

49 Common Selenium Exceptions and How to Fix Them (Python WebDriver 4.50.0)

By Freedom251 Team · · 11 min read

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.

Most Selenium failures are diagnosed faster by identifying the failing layer—synchronization, locator and page state, DOM or browsing context, element interaction, or browser-session setup—than by adding retries. Selenium’s project documentation says, “The most common Selenium-related error is a result of poor synchronization.” Start by checking that the expected page and state exist, then verify the selector, context, hit target, and driver session in that order.

The checklist below is scoped to names documented by the Selenium Python 4.50.0 API, including legacy and protocol-level classes that can still appear in Python projects. Other bindings can expose different names or hierarchies; do not assume Java, JavaScript, C#, and Ruby inventories are identical. The official references are Selenium’s common-errors guide and the Python 4.50.0 exception catalog.

As an Amazon Associate I earn from qualifying purchases.

Diagnose the failure layer before changing code

  1. State and timing: confirm navigation completed and wait for the condition your next action needs, not an arbitrary sleep.
  2. Locator: inspect the live DOM and check that the selector syntax matches the strategy (CSS, XPath, ID, and so on).
  3. DOM and context: determine whether the node was replaced, the page navigated, or the script switched frames or windows.
  4. Interaction: verify that the element is displayed, enabled, in the viewport, and unobstructed at its center point.
  5. Session and environment: check that the browser, driver, permissions, and WebDriver session are still usable.

Capture the URL, current title, current window handles, active frame, selector, and a screenshot at the failure point. Reproduce in another browser when possible; Selenium notes that an apparent Selenium error can originate in the underlying browser driver.

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

Timing, lookup, and selector exceptions

For Python, prefer an explicit wait with a bounded timeout and a condition that represents readiness:

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
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, 15)
button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.submit")))
button.click()

Do not make every failure “go away” by increasing the timeout. A wrong page or selector will never become ready.

49 exceptions: meaning, verification, and proportionate fix

  1. WebDriverException: the base WebDriver error. Verify the complete traceback and driver log; fix the more specific underlying condition rather than catching this broadly.
  2. ConnectionClosedException: the connection to the remote driver closed. Check driver or grid logs and network stability; create a new session after fixing the infrastructure.
  3. NoSuchDriverException: Selenium could not locate or start the driver. Check Selenium Manager output, executable permissions, PATH, and the configured Service path.
  4. InvalidArgumentException: a command received an invalid value. Log the exact arguments and compare them with the WebDriver command’s accepted types and ranges.
  5. InvalidSessionIdException: a command targeted a closed or deleted session. Check for commands after quit() or after closing the last tab; keep lifecycle ownership in one place.
  6. NoSuchSessionException: the remote end has no matching session. Verify that the session was created successfully and was not torn down by a fixture or grid.
  7. SessionNotCreatedException: a browser session could not be created. Compare browser and driver versions, confirm the browser binary exists, and inspect operating-system restrictions and permissions.
  8. UnreachableBrowserException: the running browser became unreachable. Check crashes, container limits, process cleanup, and driver logs; restart the browser only after finding the environmental cause.
  9. RemoteDriverServerException: the remote driver server failed. Inspect the Selenium Grid or remote endpoint logs, health, authentication, and network route.
  10. UnknownErrorException: the remote end returned an unspecified error. Preserve the response and driver log, then reproduce with a local or alternate driver to isolate the implementation.
  11. UnknownMethodException: the endpoint does not support the requested command. Check binding and driver versions and remove nonstandard commands.
  12. UnsupportedCommandException: the driver does not implement that command. Use a WebDriver-standard alternative or a driver version that supports the required operation.
  13. TimeoutException: an explicit wait or command exceeded its limit. Verify the page, selector, and readiness condition before changing the timeout.
  14. ScriptTimeoutException: asynchronous JavaScript did not call its callback before the script timeout. Inspect the callback path and set a bounded script timeout appropriate to the operation.
  15. NoSuchElementException: no matching element existed at lookup time. Verify the current URL and preceding action, inspect the live DOM, correct the locator, or wait for the element to appear.
  16. InvalidSelectorException: selector syntax is malformed or paired with the wrong strategy. Validate CSS or XPath independently and ensure By.CSS_SELECTOR is not given XPath (or vice versa).
  17. StaleElementReferenceException: a stored element handle no longer points to the current DOM node. Reacquire it after a refresh, navigation, re-render, or DOM replacement; restore the correct frame or window first if context changed.
  18. DetachedShadowRootException: a previously obtained shadow root was detached. Re-find the host and obtain a fresh shadow root after the component re-rendered.
  19. NoSuchShadowRootException: the host has no accessible shadow root. Verify the host selector, component state, and whether the component uses an open shadow root supported by your operation.
  20. NoSuchFrameException: the requested frame was not found. Confirm the frame element or name, wait for it, and switch with driver.switch_to.frame(...) only after locating it.
  21. NoSuchWindowException: the requested window or tab handle is absent. Log driver.window_handles, switch to a live handle, and avoid using handles from a previous session.
  22. InvalidSwitchToTargetException: a frame or window switch target is invalid. Verify the target belongs to the current session and that the page has finished creating it.
  23. ElementNotInteractableException: the element cannot perform the requested action in its current state. Check that the locator selects the intended control, it is displayed and enabled, and it is within a usable viewport.
  24. ElementClickInterceptedException: another element would receive the click at the target’s center. Wait for overlays, modals, sticky headers, and animations to finish; scroll or reposition the target, then click it normally.
  25. ElementNotSelectableException: the option or control cannot be selected. Verify that the element is the selectable control (for example, an option in the correct select) and that application state permits selection.
  26. ElementNotVisibleException: a legacy visibility failure indicates the element is hidden. Inspect CSS, collapsed containers, and responsive layout; wait for visibility instead of forcing a click.
  27. InvalidElementStateException: the element’s state does not allow the requested command. Check disabled, read-only, selected, or otherwise invalid state and perform the prerequisite UI action.
  28. MoveTargetOutOfBoundsException: a pointer move target lies outside the viewport or document bounds. Scroll to a valid position and verify coordinates before moving.
  29. InvalidCoordinatesException: supplied pointer coordinates are invalid. Log the computed coordinates and use an element-relative action or a point inside the viewport.
  30. UnexpectedTagNameException: a convenience wrapper received the wrong HTML tag. Confirm the locator points to the expected tag, such as <select> for Selenium’s Select helper.
  31. JavascriptException: JavaScript execution failed. Check browser-console errors, arguments, page readiness, and whether the script references nodes that no longer exist.
  32. ScreenshotException: the driver could not capture a screenshot. Check that the session is alive, the output path is writable, and the driver supports screenshots in the current mode.
  33. InsecureCertificateException: TLS certificate validation failed. Use a correctly trusted certificate in test environments; only enable the browser’s insecure-certificate option when that trade-off is intentional.
  34. ImeActivationFailedException: the input-method editor could not be activated. Verify OS language/IME support and driver capability, or avoid IME commands when ordinary text input is sufficient.
  35. ImeNotAvailableException: the requested IME is unavailable. Check the host’s installed input methods and run the test on an environment that provides the required IME.
  36. UnexpectedAlertPresentException: an unexpected alert blocked the command. Detect and accept or dismiss the alert deliberately, then fix the application flow that created it.
  37. NoAlertPresentException: code tried to access an alert that is not open. Wait for alert presence and ensure a prior action actually triggers it.
  38. NoSuchCookieException: the named cookie does not exist in the current cookie store. Confirm domain, path, timing, and cookie name after navigation.
  39. InvalidCookieDomainException: the cookie is being added to a domain that does not match the current page. Navigate to the correct host before adding it and follow cookie-domain rules.
  40. UnableToSetCookieException: the browser rejected the cookie. Check expiry, secure and same-site attributes, domain/path, size, and whether the current context permits cookies.
  41. NoSuchAttributeException: a requested attribute is absent (a legacy lookup failure). Inspect the live markup and use the current element-property APIs; do not assume an attribute exists.
  42. CookieNotFoundException: a cookie deletion or lookup targeted a missing cookie. Log cookies immediately before the operation and correct the name, domain, or path.
  43. NotFoundException: a requested WebDriver resource was not found. Preserve the command and response, then verify the target session, handle, frame, or element at the point of failure.
  44. InvalidElementStateException (legacy protocol occurrence): some drivers report this generic state error instead of a more specific interaction class. Inspect displayed, enabled, selected, and editable state and use the specific remedy above.
  45. ElementNotVisibleException (legacy protocol occurrence): older drivers may return this name for hidden controls. Verify visibility and viewport placement, then wait for the application’s visible state.
  46. UnknownErrorException (driver-specific occurrence): a driver may wrap a browser-specific failure in this generic class. Reproduce with another browser and inspect the driver log before changing test logic.
  47. WebDriverException (session-start occurrence): a generic startup traceback can hide a binary, permission, or capability problem. Run the same capabilities manually, print browser and driver versions, and correct the environment.
  48. RemoteDriverServerException (grid occurrence): a grid may expose this while a node is draining or unavailable. Check node registration, capacity, authentication, and proxy timeouts before retrying.
  49. ConnectionClosedException (transport occurrence): a proxy or network can close an otherwise valid command. Check idle timeouts, keep-alive settings, and packet loss; then rerun with a healthy route.
  50. InvalidArgumentException (capability occurrence): malformed capabilities can prevent a session before any page loads. Print the final capabilities payload and remove unsupported or incorrectly typed keys.
  51. TimeoutException (navigation occurrence): page-load timeout can leave a partially loaded document. Record the URL and ready state, decide whether the page is usable, and fix network or resource blocking rather than blindly extending the limit.

The last entries describe distinct ways the same protocol classes surface in real Python traces; the Python API reference is the authority for the class names and inheritance in your installed version.

Reliable Python patterns for the common failures

Wait for a state, not a delay

from selenium.webdriver.support import expected_conditions as EC
wait.until(EC.visibility_of_element_located((By.ID, "results")))
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".modal")))

Reacquire after DOM replacement

locator = (By.CSS_SELECTOR, "button.save")
wait.until(EC.element_to_be_clickable(locator)).click()

Keep the locator, not a long-lived WebElement, when a framework frequently re-renders the component.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Restore browsing context

driver.switch_to.default_content()
driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR, "iframe#checkout"))
# interact inside the frame
driver.switch_to.default_content()

For windows, select a handle from the current driver.window_handles list and never reuse handles from another session.

Make click interception observable

target = wait.until(EC.element_to_be_clickable((By.ID, "submit")))
driver.execute_script("arguments[0].scrollIntoView({block:'center'});", target)
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".loading, .modal")))
target.click()

JavaScript clicks can bypass hit testing and hide a real UI defect; use them only when the application’s behavior explicitly requires it.

Browser and driver setup checks

  1. Print the browser version inside the test environment and the driver version reported by the driver log.
  2. Confirm the browser binary and driver are executable by the test user and not blocked by container or operating-system policy.
  3. Use current Selenium Manager behavior or the binding’s Service configuration instead of copying obsolete driver-path recipes. See Selenium’s driver-location guidance.
  4. Run a minimal session with no application code. If that fails, locator changes cannot help.
  5. For remote runs, verify grid node health, proxy timeouts, capabilities, and authentication.

Or skip the browser setup

When you only need a clean reference image of a page for debugging or documentation, ScreenshotNeo can return it with one request. It accepts consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

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 capture options such as full-page lazy-image loading, CSS-selector element capture, device presets, custom waits, headers, cookies, geolocation, PDF output, signed links, async webhooks, bulk capture, caching, and usage reporting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

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

There is a free plan with 1,000 screenshots per month and no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

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

FAQ

Should I catch WebDriverException and retry?

No. Catch specific classes, record the page and driver state, and retry only an operation proven to be transient. Retrying a wrong selector, closed session, or incompatible driver only obscures the cause.

Why does a selector work manually but fail in Selenium?

The automated lookup may run before rendering completes, inside the wrong frame or window, or against a different responsive DOM. Log URL, handles, frame context, and the live markup at failure time.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

When is a stale-element retry appropriate?

Only when you have established that a known re-render replaces the node. Re-find using the original locator after the replacement condition; do not loop indefinitely.

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

How can I tell whether a click problem is timing or layout?

Inspect the element’s displayed and enabled state, scroll it to the center, and identify the element at its center point. If another node owns that point, the problem is obstruction or layout, not simply a longer wait.

Frequently Asked Questions

Does Selenium have one official list of exactly 49 exceptions?

No. The Python 4.50.0 API catalog and other language bindings expose different names and inheritance. This article scopes its checklist to Python names and common protocol occurrences.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

What should I capture in a failure report?

Record the exception traceback, URL and title, browser and driver versions, window handles, active frame, locator, relevant DOM, screenshot, and driver or grid logs.

Can Selenium Manager replace every manual driver setup?

It can manage supported driver discovery in current Selenium environments, but permissions, browser availability, network policy, and remote-grid configuration still require verification.

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.

browser automationDebuggingPythonSeleniumtest automationWebDriver

Leave a Reply

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

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

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.