Selenium

4.41.0 · active · verified Fri Mar 27

Python bindings for Selenium WebDriver — browser automation for Chrome, Firefox, Edge, Safari. Current version is 4.41.0 (Feb 2026). Requires Python >=3.10. Selenium Manager (built-in since 4.6) automatically downloads and manages browser drivers — manual chromedriver management is no longer needed. All find_element_by_*() shorthand methods were removed in Selenium 4.

Warnings

Install

Imports

Quickstart

Modern Selenium 4 pattern. Selenium Manager handles chromedriver. Always use WebDriverWait.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options

# Selenium Manager downloads chromedriver automatically
options = Options()
options.add_argument('--headless=new')  # new headless mode
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

driver = webdriver.Chrome(options=options)

try:
    driver.get('https://example.com')
    
    # Wait for element before interacting
    wait = WebDriverWait(driver, timeout=10)
    button = wait.until(
        EC.element_to_be_clickable((By.ID, 'submit-btn'))
    )
    button.click()
    
    # Find elements
    items = driver.find_elements(By.CSS_SELECTOR, '.product-item')
    print(f'Found {len(items)} items')
finally:
    driver.quit()

view raw JSON →