selenium
Browser automation library via WebDriver protocol — controls Chrome, Firefox, Edge, Safari through their respective WebDriver implementations. selenium 4.x features: webdriver.Chrome/Firefox/Edge with options, driver.get(url), driver.find_element(By.CSS_SELECTOR/XPATH/ID/NAME), WebDriverWait + expected_conditions for dynamic content, ActionChains for complex interactions (drag-drop, hover, keyboard), execute_script() for JavaScript, frame switching, alert handling, window management, network conditions (via BiDi), and selenium-manager for automatic driver downloads. Long-established standard for web automation.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Browser automation. Passwords typed via send_keys() appear in logs if not suppressed. Remote WebDriver connections should use HTTPS. Browser profile/cookies contain session tokens — protect temporary directories. Headless browsers can be detected by sophisticated sites.
⚡ Reliability
Best When
Maintaining existing selenium test suites or when specific browser features require WebDriver protocol — selenium remains viable for cross-browser testing infrastructure already built on it.
Avoid When
New projects (use playwright), high-volume scraping (use scrapy/httpx), static pages (use requests+BS4), or Python 3.11+ with modern async (use playwright).
Use Cases
- • Agent web automation — from selenium import webdriver; from selenium.webdriver.common.by import By; driver = webdriver.Chrome(); driver.get(url); driver.find_element(By.ID, 'search').send_keys(query); driver.find_element(By.CSS_SELECTOR, 'button[type=submit]').click(); result = driver.find_element(By.CSS_SELECTOR, '.result').text; driver.quit() — basic automation; agent controls browser
- • Agent wait for dynamic content — from selenium.webdriver.support.ui import WebDriverWait; from selenium.webdriver.support import expected_conditions as EC; wait = WebDriverWait(driver, 30); element = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '.loaded'))); text = element.text — explicit wait; agent waits for JS-rendered content
- • Agent JavaScript execution — result = driver.execute_script('return document.querySelector(".data").innerText'); driver.execute_script('arguments[0].scrollIntoView()', element); driver.execute_script('window.scrollTo(0, document.body.scrollHeight)') — JS execution; agent runs arbitrary JavaScript; useful for scroll, click hidden elements, extract computed values
- • Agent headless Chrome — options = webdriver.ChromeOptions(); options.add_argument('--headless=new'); options.add_argument('--no-sandbox'); options.add_argument('--disable-dev-shm-usage'); driver = webdriver.Chrome(options=options) — headless; agent runs browser without display; --no-sandbox required in Docker/CI; --disable-dev-shm-usage for container memory
- • Agent complex interaction — from selenium.webdriver.common.action_chains import ActionChains; actions = ActionChains(driver); actions.move_to_element(menu).click(submenu).perform() — action chains; agent performs hover, drag-drop, right-click, and multi-step interactions; actions.perform() executes entire chain
Not For
- • New automation projects — playwright has better auto-wait, more reliable locators, and faster execution; prefer playwright for new work
- • High-volume scraping — selenium is slow per request; use scrapy or direct HTTP for scale
- • Static HTML scraping — selenium launches full browser (1-2s startup); for static HTML use requests + BeautifulSoup
Interface
Authentication
No auth for the library. Supports cookies and HTTP auth for target websites.
Pricing
selenium is Apache 2.0 licensed. Selenium Manager (4.x+) handles driver downloads automatically.
Agent Metadata
Known Gotchas
- ⚠ StaleElementReferenceException after page change — finding element before navigate, then using after navigate raises StaleElementReferenceException; element reference invalidated by DOM changes; agent code: re-find elements after navigation; never store element references across page loads; find_element every time needed
- ⚠ driver.quit() vs driver.close() — driver.close() closes current window only; driver.quit() closes all windows AND kills WebDriver process; agent code: always call driver.quit() in try/finally; missing quit() leaves chromedriver process running; use: try: ... finally: driver.quit()
- ⚠ Implicit vs explicit waits — driver.implicitly_wait(10) makes all find_element calls wait up to 10s; mixing implicit and explicit waits causes unpredictable timeouts; agent code: use WebDriverWait (explicit) only; set implicit_wait to 0; explicit: wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '.btn')))
- ⚠ selenium-manager vs chromedriver — selenium 4.6+ includes selenium-manager that auto-downloads matching chromedriver; older setups need webdriver-manager package or manual chromedriver; agent code with selenium 4.x: no driver setup needed; older selenium: from webdriver_manager.chrome import ChromeDriverManager; driver = webdriver.Chrome(ChromeDriverManager().install())
- ⚠ find_element vs find_elements — find_element(By.CSS, '.item') raises NoSuchElementException if not found; find_elements(By.CSS, '.item') returns [] if not found; agent code: use find_elements for presence check (if elements: ...); use find_element when element guaranteed to exist; both return stale after DOM update
- ⚠ Headless Chrome flags differ by version — Chrome 112+ uses --headless=new (modern headless); older Chrome uses --headless (deprecated); agent code: options.add_argument('--headless=new') for Chrome 112+; Docker containers need --no-sandbox and --disable-dev-shm-usage; CI may need --disable-gpu; user-data-dir conflicts in parallel
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for selenium.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.