SoftwareTestPilot
Automation TestingPublished: 18 min read

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.

Avinash K
Founder & QA Engineer at SoftwareTestPilot
Share:XLinkedInWhatsApp
Selenium WebDriver complete guide 2026 — Selenium 4 relative locators, BiDi, Grid 4.
Selenium WebDriver complete guide 2026 — Selenium 4 relative locators, BiDi, Grid 4.

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 locatorsabove, 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.xml

Deeper: 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.24

Point 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.

Frequently asked questions

1.Is Selenium dead in 2026?
No. It powers the majority of enterprise regression suites. Selenium 4 modernized the API and Grid — the platform is actively maintained.
2.Selenium or Playwright for a new project?
Playwright unless you have Selenium Grid infrastructure, Java-heavy skills, or vendor lock-in on tools that only integrate with WebDriver.
3.Which Selenium binding is best?
Java has the most jobs; Python has the fastest onboarding; C# for .NET shops. All three are first-class.
4.How does Selenium handle Shadow DOM?
Selenium 4 added getShadowRoot() on WebElement. Works for open shadow roots; closed roots are inaccessible by design.
5.What is the biggest Selenium anti-pattern in 2026?
Sleeping instead of waiting, and using absolute XPath. Both cause the majority of flaky failures.