Selenium WebDriver Complete Guide 2026
The complete 2026 Selenium WebDriver guide — install, first test, locators, waits, Selenium 4 features (relative locators, BiDi, Grid 4), framework design, and CI.

Last updated 2026-07-20 · 18 min read · By Avinash K
Selenium is still the most-installed test tool on Earth in 2026, powering the majority of enterprise regression suites. Selenium 4 modernized the API — relative locators, native BiDi protocol, container-first Grid — while keeping backward compatibility. This guide gets you productive fast.
1. Install and first test in 5 minutes
// Maven
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.24.0</version>
</dependency>
WebDriver driver = new ChromeDriver();
driver.get("https://softwaretestpilot.com");
driver.findElement(By.linkText("Jobs")).click();
driver.quit();Selenium Manager (built-in since 4.11) auto-downloads the right driver binary — no more WebDriverManager for most cases.
2. Locators — including Selenium 4 relative locators
// Classic
driver.findElement(By.id("email"));
driver.findElement(By.cssSelector("button[data-testid='submit']"));
// Selenium 4 — relative locators
import static org.openqa.selenium.support.locators.RelativeLocator.with;
WebElement password = driver.findElement(with(By.tagName("input")).below(By.id("email")));3. Waits — never use Thread.sleep
// ✅ Explicit wait
new WebDriverWait(driver, Duration.ofSeconds(10))
.until(ExpectedConditions.elementToBeClickable(By.id("submit")));
// ❌ Never
Thread.sleep(3000);4. Selenium 4 features you should use in 2026
- BiDi protocol — subscribe to console logs, network events, JS errors.
- Relative locators —
above,below,toLeftOf,toRightOf,near. - New Grid 4 — Docker-first, observable via OpenTelemetry.
- Chrome DevTools Protocol — throttle network, emulate geolocation.
The official Selenium WebDriver docs stay the canonical reference.
5. Framework design — POM + TestNG
Reference structure:
src/test/java/
pages/ ← Page Objects
tests/ ← @Test classes
base/ ← BaseTest with driver setup
utils/ ← waits, data helpers
testng.xmlDeeper: Java for Selenium.
6. Selenium Grid 4 in Docker
docker network create grid
docker run -d --net grid --name selenium-hub selenium/hub:4.24
docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-chrome:4.24Point your driver at http://localhost:4444/wd/hub. Scale nodes horizontally as you add parallel tests.
7. CI wiring — GitHub Actions with Grid
Run Grid as a service container, execute your Maven Surefire suite, publish Allure or ExtentReports as artifacts. See GitHub Actions + Selenium CI.