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

If PhantomJS is failing in a Python Selenium script, migrate the script to headless Chrome or Firefox: PhantomJS development is suspended, and Selenium deprecated its integration in favor of those browsers. For other errors, first identify whether the failure is driver discovery, browser startup, or page synchronization; each needs a different fix.

Why PhantomJS errors need a different fix

PhantomJS is a legacy browser-automation route, not a driver you should keep reinstalling to make a current Selenium project work. The PhantomJS project says, “Important: PhantomJS development is suspended until further notice.” Selenium’s 3.8.1 change log likewise deprecated PhantomJS and recommended headless Chrome or Firefox. See the PhantomJS project and Selenium change log.

Replace calls such as webdriver.PhantomJS(...) and PhantomJS-specific desired capabilities. Do not treat a hard-coded PhantomJS executable path or an old driver download as the standard fix for modern Selenium. Current Selenium Python documentation describes Selenium Manager, which can handle browser and driver setup when a WebDriver is instantiated. See Selenium Manager.

Start with a reproducible Python setup

Use a virtual environment so the Selenium version you diagnose is the one your script actually imports. Select Chrome or Firefox, install it in the environment where the script will run, and verify your Python, Selenium, browser, operating system, and execution context (local machine, CI, or remote browser) before changing driver configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.
  1. Create and activate a virtual environment: python -m venv .venv. On macOS or Linux, activate it with source .venv/bin/activate; on Windows PowerShell, use .venvScriptsActivate.ps1.

  2. Install or update Selenium in that environment: python -m pip install --upgrade selenium.

  3. Confirm the interpreter and package: python --version and python -m pip show selenium.

  4. Install the intended browser if it is not already available. In CI, confirm it is present in the actual runner image, not only on your development machine.

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

Selenium Manager may obtain the required driver when the browser’s WebDriver is created. That behavior does not mean every environment can download a driver: network restrictions, browser installation, permissions, or stale explicit paths can still prevent startup.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Replace PhantomJS with headless Chrome or Firefox

Use the browser’s Options API to request headless operation. The following minimal scripts use current Selenium Python patterns and let Selenium Manager handle driver discovery. Run the one for the browser installed in your environment.

Headless Chrome

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    print(driver.title)
finally:
    driver.quit()

Headless Firefox

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options)
try:
    driver.get("https://example.com")
    print(driver.title)
finally:
    driver.quit()

Headless means the browser runs without a visible window; it is still a real browser, so rendering and JavaScript behavior can differ from PhantomJS. Choose Chrome or Firefox based on the target site’s rendering and JavaScript compatibility, what your CI image supports, startup and resource needs in your deployment, and the browser’s available logs and debugging tools. Selenium identifies both as migration targets but does not establish a universal speed or reliability winner.

Diagnose the error by its WebDriver failure class

Read the exception type and the first useful driver-log message before changing code. Selenium’s troubleshooting guidance separates driver-location, session-creation, element, stale-element, click-interception, and timeout failures. Record Python, Selenium, browser, driver (if separately installed), OS, and whether the run is local, CI, or remote.

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.

NoSuchDriverException: Selenium cannot locate the driver

This points to driver discovery or installation, not an element missing from the page. Selenium’s driver-location guide defines the failure as inability to find the required executable.

  • Check that the browser you selected is installed and is the one your code intends to launch.

    Rank #3
    Sale
    Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
    • 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.
  • Upgrade Selenium and try its normal WebDriver construction path so Selenium Manager can manage setup.

  • Inspect Selenium Manager diagnostics and the driver’s reported location. Check whether an old executable path or Service setting overrides normal discovery.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If you intentionally manage a driver yourself, verify the executable exists at the configured path, is executable, and is reachable in the runtime environment. Check PATH and CI image contents as well.

For explicit configuration, use Selenium’s Service class for the selected browser and point it to the actual driver executable; remove the configuration again if it points to a stale or incompatible binary. Consult the current Selenium API for the browser you use rather than copying PhantomJS-era setup.

SessionNotCreatedException: the browser session did not start

This occurs after Selenium attempts to create a WebDriver session. Compare the browser and driver versions if you manage them separately, and remove old hard-coded paths that might select a different driver than expected. Read the driver log for the specific startup failure rather than assuming every session error is a version mismatch.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

NoSuchElementException or a timeout: the page is not in the expected state

A successful navigation request does not prove that dynamic page content is ready. Selenium identifies poor synchronization as its most commonly reported error. Prefer an explicit wait for the state your next action requires, rather than a guessed fixed sleep. See Selenium waits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

wait = WebDriverWait(driver, 10)
button = wait.until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "button.submit"))
)
button.click()

Replace the example selector with one that matches your page. If the wait still expires, check that the locator is correct and that the browser is on the expected URL. Determine whether the element is inside an iframe or a different window, and switch context before searching. Wait for the needed condition—presence, visibility, or clickability—rather than treating them as interchangeable.

StaleElementReferenceException, intercepted clicks, or non-interactable elements

A stale element was found before a page update invalidated that reference; locate it again after the update. For a click that is intercepted or an element that is not interactable, confirm the element is visible and usable, wait for clickability, and check for an overlay covering it. Also verify that Selenium is in the correct iframe and window. The exception reference distinguishes these failures from missing-driver and session-startup errors: WebDriver errors.

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

Separate application defects from browser-driver defects

When the same operation behaves differently across browsers, reproduce it in another supported browser. Selenium recommends cross-browser testing as a way to determine whether the issue is in your Selenium code or the underlying driver. A minimal reproduction should include the URL, locator, action, relevant wait, browser and Selenium versions, OS, and complete exception or driver log. Avoid changing several variables at once: first establish whether the failure is browser startup, context selection, or page timing.

Or skip the browser setup

If the job is simply to save a website screenshot rather than automate interactive browser behavior, a screenshot API can avoid maintaining browser and driver setup. ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF; its cleanup can accept consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture. Clean captures are billed; bot checks, blank pages, timeouts, failed loads, and cache hits are not. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf.

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

Install the Python dependency with python -m pip install requests, then make a request. Create an API key in ScreenshotNeo first and replace the key and target URL:

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)

See the ScreenshotNeo API documentation for request options and response details. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Start with ScreenshotNeo’s free sign-up.

Common fixes at a glance

Symptom Likely area First action
PhantomJS constructor or capabilities fail Legacy browser integration Replace PhantomJS with headless Chrome or Firefox.
NoSuchDriverException Driver installation or discovery Check browser installation, Selenium Manager diagnostics, paths, permissions, and CI image.
SessionNotCreatedException Browser startup or driver compatibility Inspect driver logs and version/configuration details; check CI restrictions.
NoSuchElementException or wait timeout Locator, context, or synchronization Verify URL and locator, switch frame/window if needed, and wait for the required state.
Stale or intercepted element Page update or interaction state Re-find the element after updates and wait for visibility/clickability; remove overlay or context issues.

Frequently Asked Questions

Can I keep using PhantomJS for a new Selenium Python project?

It is not a sound choice for a current project: PhantomJS development is suspended and Selenium deprecated its integration.

Should I always install a driver manually?

No. Current Selenium Python can use Selenium Manager when creating a WebDriver, though restricted networks or environment configuration can still require you to investigate setup.

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

How do I know whether an element error is really a timing issue?

Check the current URL, locator, frame/window context, and the element state being awaited; then use an explicit wait for that state.

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.