{"id":226,"library":"selenium","title":"Selenium","description":"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.","status":"active","version":"4.41.0","language":"python","source_language":"en","source_url":"https://github.com/SeleniumHQ/selenium/releases","tags":["browser-automation","testing","web-scraping","webdriver","chrome","firefox","e2e"],"install":[{"cmd":"pip install selenium","lang":"bash","label":"Standard — Selenium Manager handles driver downloads automatically"}],"dependencies":[{"reason":"Required. Installed automatically.","package":"urllib3","optional":false},{"reason":"Required for async support. Installed automatically.","package":"trio","optional":false},{"reason":"Required. Installed automatically.","package":"certifi","optional":false}],"imports":[{"note":"All find_element_by_*() and find_elements_by_*() shorthand methods were removed in Selenium 4. Use find_element(By.X, value) and find_elements(By.X, value) instead.","wrong":"# Selenium 3 shorthand methods — removed in Selenium 4:\ndriver.find_element_by_id('username')          # AttributeError\ndriver.find_element_by_css_selector('.item')    # AttributeError\ndriver.find_element_by_xpath('//button')        # AttributeError\ndriver.find_elements_by_class_name('item')      # AttributeError","symbol":"webdriver","correct":"from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\n\n# Selenium Manager handles chromedriver automatically\ndriver = webdriver.Chrome()\ndriver.get('https://example.com')\n\n# Correct element finding (Selenium 4)\nelement = driver.find_element(By.ID, 'username')\nelements = driver.find_elements(By.CSS_SELECTOR, '.item')\n\ndriver.quit()"}],"quickstart":{"code":"from selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.webdriver.chrome.options import Options\n\n# Selenium Manager downloads chromedriver automatically\noptions = Options()\noptions.add_argument('--headless=new')  # new headless mode\noptions.add_argument('--no-sandbox')\noptions.add_argument('--disable-dev-shm-usage')\n\ndriver = webdriver.Chrome(options=options)\n\ntry:\n    driver.get('https://example.com')\n    \n    # Wait for element before interacting\n    wait = WebDriverWait(driver, timeout=10)\n    button = wait.until(\n        EC.element_to_be_clickable((By.ID, 'submit-btn'))\n    )\n    button.click()\n    \n    # Find elements\n    items = driver.find_elements(By.CSS_SELECTOR, '.product-item')\n    print(f'Found {len(items)} items')\nfinally:\n    driver.quit()","lang":"python","description":"Modern Selenium 4 pattern. Selenium Manager handles chromedriver. Always use WebDriverWait."},"warnings":[{"fix":"Replace find_element_by_id('x') with find_element(By.ID, 'x'). Replace find_element_by_css_selector('.x') with find_element(By.CSS_SELECTOR, '.x'). Import: from selenium.webdriver.common.by import By","message":"All find_element_by_*() shorthand methods removed in Selenium 4. driver.find_element_by_id(), find_element_by_xpath(), find_element_by_css_selector(), find_elements_by_class_name() etc. all raise AttributeError. Still the most common LLM-generated Selenium footgun.","severity":"breaking","affected_versions":">= 4.0"},{"fix":"Pin selenium<4.33 for Python 3.9 environments.","message":"Python 3.9 dropped in Selenium 4.33+. Now requires Python >=3.10.","severity":"breaking","affected_versions":">= 4.33"},{"fix":"Use Options objects instead: options = ChromeOptions(); options.set_capability('key', 'value'). Pass options= to the WebDriver constructor.","message":"desired_capabilities parameter deprecated and removed from WebDriver constructors. Passing desired_capabilities= raises TypeError in modern Selenium 4.","severity":"breaking","affected_versions":">= 4.0"},{"fix":"Replace --headless with --headless=new in ChromeOptions. The new headless renders pages more like a real browser.","message":"options.add_argument('--headless') (old Chrome headless) deprecated. Chrome switched to a new headless implementation — use --headless=new instead.","severity":"breaking","affected_versions":">= 4.8 with Chrome 112+"},{"fix":"Remove manually downloaded chromedriver from PATH and let Selenium Manager handle it. Or pin a specific driver version via Service(executable_path='...').","message":"Selenium Manager automatically downloads matching browser drivers since 4.6. Manually downloading chromedriver and putting it on PATH is no longer necessary — but if you have a stale chromedriver on PATH, it may conflict with Selenium Manager.","severity":"gotcha","affected_versions":">= 4.6"},{"fix":"Always use WebDriverWait with expected_conditions: wait = WebDriverWait(driver, 10); element = wait.until(EC.presence_of_element_located((By.ID, 'element-id')))","message":"Not using WebDriverWait causes flaky tests. Immediately calling find_element() after page navigation often fails because the element hasn't loaded yet.","severity":"gotcha","affected_versions":"all"},{"fix":"Use try/finally: try: ... finally: driver.quit(). Or use with statement with a context manager wrapper.","message":"driver.quit() must be called to close the browser process. Using driver.close() only closes the current window but leaves the browser process running. Always use try/finally or context manager.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T12:02:16.777Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Use `driver.find_element(By.ID, \"element_id\")` after importing `By` from `selenium.webdriver.common.by`.","cause":"The `find_element_by_*` methods were deprecated and removed in Selenium 4, replaced by the more generic `find_element()` method using the `By` enum.","error":"AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'"},{"fix":"Ensure the driver executable is in your system's PATH, or provide its explicit path to the `Service` object: `from selenium.webdriver.chrome.service import Service; service = Service(executable_path='/path/to/chromedriver'); driver = webdriver.Chrome(service=service)`.","cause":"Selenium WebDriver (version 4.41.0, which predates Selenium Manager being built-in) could not locate the browser driver executable (e.g., `chromedriver`) in your system's PATH.","error":"selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH."},{"fix":"Verify the locator (CSS selector, XPath, ID, etc.) is correct, and use explicit waits (`WebDriverWait`) to wait for the element's presence or visibility before attempting to interact with it.","cause":"The WebDriver failed to find an element on the webpage matching the provided locator, often due to an incorrect locator, or the element not being loaded or present on the page yet.","error":"selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element"},{"fix":"Instantiate a `Service` object with the driver path and pass it to the browser driver constructor: `from selenium.webdriver.chrome.service import Service; service = Service(executable_path='/path/to/chromedriver'); driver = webdriver.Chrome(service=service)`.","cause":"In Selenium 4, passing `executable_path` directly to the browser driver constructor (e.g., `webdriver.Chrome()`) is deprecated; a `Service` object should be used instead for configuring the driver.","error":"DeprecationWarning: executable_path has been deprecated, please pass in a Service object"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"52.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"53M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.1,"disk_size":"57.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.1,"disk_size":"58M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":0.9,"disk_size":"48.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":0.9,"disk_size":"49M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.03,"mem_mb":1.2,"disk_size":"48.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.02,"mem_mb":1,"disk_size":"49M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":13.5,"disk_size":"52.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.39,"mem_mb":13.5,"disk_size":"53M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}