🟢 Selenium WebDriver

Learn Selenium WebDriver with Java, Python and TypeScript examples, locator strategies, waits, frames, real-world automation scenarios and interview questions.

Learn Selenium from scratch: installation, locators, actions, wait strategies, frames, CDP & BiDi, virtual authenticators, Selenium IDE, Grid 4, common errors, and 50 interview questions.

What you can learn on this page

  • 🟢 What is Selenium? How Does It Work? — Selenium is a W3C-standard protocol that replaces human fingers on a browser — analogous to Java's JDBC: you write against a standard interface and the underlying driver implementation (ChromeDriver, GeckoDriver, EdgeDriver) is swappable. But if you already ha
  • ⚙️ Installation — Java, Python, TypeScript — Setting up Selenium mirrors adding a Maven dependency in Java — but with an extra layer: your test code connects to a browser driver (ChromeDriver), which in turn connects to the actual Chrome binary. Just like a JDBC driver bridges Java code to a database. Bu
  • 🎯 Locators — Element Finding Strategies — Choosing a locator directly mirrors choosing a collection access strategy in Java: By.id is a Map key lookup — O(1), the browser calls getElementById internally. By.xpath, by contrast, works like scanning an unsorted List — it may traverse the entire DOM tree.
  • ⚡ Actions — All User Interactions — Selenium's Actions API is the Builder pattern applied to browser gestures: instead of sending commands one by one, you chain moves together and dispatch the whole sequence with a single .perform() — just like appending to a Java StringBuilder and calling toStr
  • ⏳ Wait Strategies — Handling Timing Issues — Think of a wait strategy as the difference between two ways of collecting someone from the airport. Thread.sleep(3000) is agreeing to stand at the arrivals gate at exactly 14:00 no matter what: if the plane lands early you were not there yet, if it is delayed
  • 🪟 Frames, Alerts & Multiple Windows — An iframe is a separate DOM context embedded inside the main page — analogous to loading a second ClassLoader inside a Java ClassLoader: you cannot reach inner elements with findElement from the outer context; you must call driver.switchTo().frame() first to e
  • 🏗️ Framework Architecture (SOLID + POM) — Every piece you have written up to this tab (findElement calls, WebDriverWait blocks, @Test methods) works on its own but is LOOSELY connected — like an industrial park that grew without a zoning plan: every workshop installs its own generator, runs its own wa
  • 🛠️ Real World — E-Commerce Test Scenario — Think of a unit test as inspecting each part of a car on the workbench — the brake pad, the fuel pump, the wiring loom — and an E2E test as actually driving the assembled car around the block. Every part can pass its bench inspection while the car still fails