🟢 Selenium WebDriver

Selenium is an open-source automation tool that drives real web browsers the way a human user would. It speaks the W3C WebDriver standard, so the same test code runs on Chrome, Firefox, Edge and Safari, and you can write it in Java, Python, JavaScript, C# or Ruby. Its most common use is automating the regression tests a team would otherwise repeat by hand on every release.

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

Frequently Asked Questions

What is Selenium?

Selenium is an open-source automation tool that controls web browsers the way a real user would. It follows the W3C WebDriver standard and can be used with Java, Python, JavaScript or C#.

What is the difference between Selenium and Playwright?

Playwright has built-in auto-waiting that waits for an element to actually be actionable before interacting with it; in Selenium you build that waiting logic yourself with WebDriverWait. Selenium has a wider ecosystem and a much longer track record in the industry.

How long does it take to learn Selenium?

You can learn basic locators and actions in a few days; reaching interview-ready level — including wait strategies, the Page Object Model and framework architecture — usually takes 4-6 weeks of regular practice.

Is Selenium free?

Yes, Selenium is completely free and open-source (Apache 2.0 license). You never pay a license fee for any of its components, including Selenium Grid.

Which languages does Selenium support?

Official Selenium client libraries exist for Java, Python, JavaScript (Node.js), C# and Ruby. Java is the most common choice in enterprise QA projects.

What is the most common Selenium error?

`StaleElementReferenceException` — once the page re-renders in any way, the element reference you were holding no longer points to a valid DOM node. The fix is to re-locate the element or use the correct wait strategy.

What is most commonly asked in a Selenium interview?

The difference between explicit and implicit wait, and why the two should not be mixed. Follow-up questions usually cover what problem the Page Object Model solves and how you would debug a flaky test scenario like `StaleElementReferenceException`.