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

Install Selenium in the Python environment that will run your script, then start Chrome with webdriver.Chrome(). In a typical current setup, Selenium Manager can locate or obtain a compatible driver automatically, so you usually do not need to download ChromeDriver yourself.

Install Selenium in the right Python environment

Using a virtual environment helps ensure that Selenium is installed for the same Python interpreter that runs your script. From your project directory, create and activate one, then install or update Selenium:

python -m venv .venv
# Activate .venv using the command for your operating system
python -m pip install -U selenium

The activation command varies by operating system and shell. After activation, python -m pip uses that environment’s interpreter. Selenium’s official Python documentation gives this installation approach: install Selenium for Python.

Run a complete Chrome example

Save this as selenium_chrome.py and run it with the Python interpreter where you installed Selenium:

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


driver = webdriver.Chrome()
try:
    driver.get("https://www.selenium.dev/selenium/web/web-form.html")
    title = driver.title

    text_box = driver.find_element(by=By.NAME, value="my-text")
    submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")
    text_box.send_keys("Selenium")
    submit_button.click()

    message = driver.find_element(by=By.ID, value="message")
    print(title, message.text)
finally:
    driver.quit()

The script opens Selenium’s demonstration form, types into the field, submits it, and prints the page title and returned message. The finally block calls driver.quit() whether the steps succeed or raise an exception, closing the browser session. This follows the flow of Selenium’s first Python script.

How ChromeDriver setup works

When you call webdriver.Chrome() without providing a driver, Selenium can use Selenium Manager to handle driver discovery. Selenium Manager is shipped with Selenium releases starting at 4.6 and is invoked by the language bindings when a driver has not otherwise been supplied. It is a fallback, not a requirement: a driver already available on PATH or one configured explicitly can also be used. See Selenium Manager documentation.

For most first runs, start with the default constructor rather than downloading ChromeDriver and maintaining a machine-specific path. For tightly controlled environments, explicitly managing versions can make the browser and driver combination more reproducible, but it also means you must keep that configuration compatible as Chrome changes.

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.

Wait for the browser state you need

A browser command can finish before a dynamic page has rendered the element your next step needs. Selenium’s documentation calls synchronizing automation with browser state one of its biggest challenges and notes that doing it well is an advanced topic. Its first-script page presents a short implicit wait only as a simple placeholder and says implicit waits are rarely the best solution.

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

For a real interaction, use an explicit wait for the required condition instead of guessing a fixed sleep. For example, to wait until a result is visible:

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

message = WebDriverWait(driver, 10).until(
    EC.visibility_of_element_located((By.ID, "message"))
)
print(message.text)

Place this in the session’s try block after the action that causes the result to appear. Choose a condition that matches the next operation: visibility before reading text, clickability before clicking. Avoid mixing implicit and explicit waits unless you understand how their timing interacts. Selenium’s guidance is in its first-script synchronization notes.

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.

Use a manual driver path only when needed

If automatic driver management does not suit your environment, Selenium supports passing a specific driver executable through Chrome’s Service object. This can be useful where driver binaries are provisioned centrally, but a hard-coded local path is less portable than the default setup.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path="/path/to/chromedriver")
driver = webdriver.Chrome(service=service)

Replace the example path with the actual executable location for your system. Selenium documents driver configuration and service options in its driver location troubleshooting guide.

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

Troubleshoot common startup and interaction failures

Chrome does not start or Selenium reports a driver error

  • Confirm that Chrome is installed and can launch on the machine running the script.
  • Update Selenium in the active environment with python -m pip install -U selenium.
  • Record the Selenium and Python versions, operating system, Chrome version, and full error text. Inspect Selenium Manager’s output for driver discovery or download problems.
  • If your environment blocks or cannot use automatic driver management, configure an explicit driver using Service and check the driver-location guidance.

The script says an element cannot be found

The page may not have reached the state where that element exists, or the locator may not match the current page. Confirm the locator against the page’s actual markup and wait for the element or relevant state before using it.

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

The browser remains open after an error

Put browser actions inside a try block and call driver.quit() in finally, as in the complete example. This closes the WebDriver session even if navigation, lookup, or interaction raises an exception.

Compatibility is unclear

Selenium’s Chrome documentation says Selenium 4 is compatible with Chrome version 75 and greater, but that broad statement does not guarantee every platform or feature combination. For version-specific issues, check the current Chrome browser guidance and the full error details.

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

Or skip the browser setup

If your goal is to capture a page as an image or PDF rather than automate browser interactions, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return a screenshot; its clean-shot steps accept cookie or consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets, with each step configurable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. AI agents can use its MCP 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.

For example, using cURL:

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 and response details. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up free for 1,000 screenshots a month, with no card required.

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.

Frequently Asked Questions

Do I need to download ChromeDriver separately to run Selenium with Chrome?

Usually not: for a typical setup, Selenium Manager can handle driver discovery when you use webdriver.Chrome().

How do I close Chrome when my Selenium script finishes?

Call driver.quit(); putting it in a finally block also ensures cleanup if an earlier step raises an error.