Selenium is an open-source browser automation framework that enables programmatic control of web browsers across multiple platforms and languages. Originally created in 2004, it has evolved into the de facto standard for web application testing and automation, with Selenium WebDriver conforming to the W3C WebDriver specification since 2018. At its core, Selenium allows you to locate elements on a page, interact with them just as a user would, and verify behavior—making it indispensable for end-to-end testing, web scraping, and repetitive browser tasks. The key mental model: Selenium doesn't "see" the page like a human does; it navigates the DOM tree, so mastering locators and understanding how pages load asynchronously are essential to writing robust, non-flaky automation.
What This Cheat Sheet Covers
This topic spans 22 focused tables and 218 indexed concepts, 120 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: WebDriver Initialization and Setup
Every Selenium script begins by spinning up a driver for a specific browser, and getting this layer right removes the single most common source of early frustration—mismatched driver versions. Since Selenium 4.6, Selenium Manager handles driver downloads automatically, so most of these one-liners just work; the rest cover remote/Grid sessions and the cleanup calls (quit() vs close()) you should never forget in teardown.
| Method | Example | Description | |
|---|---|---|---|
from selenium import webdriverdriver = webdriver.Chrome() | • Launches a Chrome browser instance • Selenium Manager auto-downloads the matching ChromeDriver since 4.6+. | ||
driver = webdriver.Firefox() | • Launches Firefox using GeckoDriver • supports full Selenium features. | ||
driver = webdriver.Edge() | • Launches Microsoft Edge (Chromium-based) • requires matching EdgeDriver version. | ||
driver = webdriver.Safari() | • Launches Safari on macOS using built-in safaridriver • enable first with safaridriver --enable in terminal. | ||
Automatic in Selenium 4.6+ | • Automatically downloads and manages browser drivers without manual setup • enabled by default in Selenium 4.6+. | ||
driver = webdriver.Remote( command_executor='http://hub:4444/wd/hub', options=chrome_options) | • Connects to a remote Selenium server or Grid • enables distributed and parallel execution. | ||
WebDriverManager.chromedriver().setup();driver = new ChromeDriver(); | • Third-party Java library that auto-resolves and downloads drivers • eliminates manual driver management. | ||
from webdriver_manager.chrome import ChromeDriverManagerdriver = webdriver.Chrome(ChromeDriverManager().install()) | • Python library for automatic driver installation • simplifies setup across platforms. | ||
driver.quit() | • Closes all browser windows/tabs and ends the WebDriver session • always call in teardown. | ||
driver.close() | • Closes only the current browser window • session stays active if other windows are open. |