Selenium interview questions
// 37 QUESTIONS Β· UPDATED MAY 2026
Selenium WebDriver interview questions covering waits, Page Object Model, Grid, parallel execution, and framework design decisions for Java, Python, and JavaScript codebases.
Showing 37 of 37 questions
- What are the different types of waits in Selenium?Junior
Implicit waits set a global polling timeout for findElement; explicit waits poll for a specific condition; fluent waits add custom pollinβ¦
- Explain the Page Object Model with a concrete example.Mid
Page Object Model wraps each page (or significant component) as a class that exposes user-level actions and hides locators. Tests stay reβ¦
- What is Selenium WebDriver and what does it do?Junior
Selenium WebDriver is a browser automation library that drives a real browser via the W3C WebDriver protocol. Your test code sends commanβ¦
- What is the difference between Selenium IDE, Selenium WebDriver, and Selenium Grid?Junior
IDE is a record-and-playback browser extension for quick scripts. WebDriver is the programmatic browser-control library you build real teβ¦
- What is a WebElement and how do you locate one?Junior
A WebElement is a Selenium handle to a DOM element on the current page. You locate one with `driver.findElement(By.<strategy>(value))` usβ¦
- List the locator strategies in Selenium and rank them by reliability.Junior
The strategies are id, name, css, xpath, class name, tag name, link text, partial link text. Practical ranking: data-test attributes viaβ¦
- What is the difference between findElement and findElements?Junior
findElement returns a single WebElement and throws NoSuchElementException if nothing matches. findElements returns a list β empty if no mβ¦
- How do you handle a dropdown in Selenium WebDriver?Junior
For native `<select>`, wrap the element in `Select` and use `selectByVisibleText`, `selectByValue`, or `selectByIndex`. For custom dropdoβ¦
- What is the difference between absolute and relative XPath?Junior
Absolute XPath starts from the document root with `/html/body/...` and depends on the full DOM hierarchy β fragile. Relative XPath startsβ¦
- How do you take a screenshot on test failure?Junior
Cast the driver to `TakesScreenshot`, call `getScreenshotAs(OutputType.FILE)`, and copy to disk. Wire it into your test framework's failuβ¦
- What is the Actions class in Selenium and when do you use it?Mid
The Actions class builds composite mouse and keyboard sequences β hover, drag-and-drop, right-click, key chords, double-click. You chainβ¦
- What is the difference between driver.close() and driver.quit()?Mid
`close()` shuts the current window/tab β the browser keeps running if other tabs exist. `quit()` ends the entire WebDriver session, killsβ¦
- Walk through how Selenium Manager (4.10+) replaces webdriver-manager.Mid
Selenium Manager is built into Selenium 4.10+ and auto-detects the installed browser version, downloads the matching driver binary, cacheβ¦
- How do you handle a StaleElementReferenceException?Mid
It means the WebElement you held a handle to was removed or replaced in the DOM. Don't catch and retry blindly β re-locate the element afβ¦
- How do you switch between windows and tabs in Selenium?Mid
Track window handles with `getWindowHandles()`, identify the new one by diffing against the original, and switch with `driver.switchTo().β¦
- How do you handle iframes in Selenium WebDriver?Mid
Switch into the frame with `driver.switchTo().frame(...)` (by element, name, or index) before interacting with elements inside it. Switchβ¦
- What is the @FindBy annotation and how does PageFactory work?Mid
@FindBy declares a locator on a WebElement field, and PageFactory.initElements wires up lazy proxies β the actual lookup happens when youβ¦
- How do you handle SSL certificate errors in tests?Mid
Set browser options to accept insecure certs: `ChromeOptions.setAcceptInsecureCerts(true)` (or the Firefox equivalent). This bypasses theβ¦
- How do you upload a file with Selenium WebDriver?Mid
For native `<input type="file">`: send the absolute file path to the input with `.sendKeys(path)` β the browser treats it as a selection.β¦
- How do you scroll to an element in the page?Mid
Use `executeScript("arguments[0].scrollIntoView({block:'center'})", element)` β reliable across browsers. Actions.moveToElement also scroβ¦
- How do you handle authentication popups (basic auth) in Selenium?Mid
Most reliable: embed credentials in the URL β `https://user:pass@host/path`. For Chromium, use Chrome DevTools Protocol's `Network.setExtβ¦
- How do you simulate keyboard shortcuts in Selenium?Mid
Use the Actions class with `keyDown` / `keyUp` / `sendKeys` to model modifier+key combinations. `Actions.keyDown(Keys.CONTROL).sendKeys("β¦
- How do you handle dynamic web elements with changing IDs?Mid
Use stable attributes the framework doesn't generate β `data-test`, role, name, or text β instead of generated ids. If you must match a gβ¦
- Explain the Selenium Grid architecture (hub/node) and when to use it.Mid
Grid distributes WebDriver tests across machines. A hub receives session requests and routes to a pool of nodes that host browsers. Use iβ¦
- How do you parameterise tests with TestNG data providers?Mid
Annotate a method with `@DataProvider(name = "...")` returning `Object[][]` β each row is one test invocation. Reference it with `@Test(dβ¦
- How would you architect a Selenium framework from scratch for a Java team?Senior
Layered: driver factory + config β page objects + components β test base classes β tests + data providers. Use Maven, TestNG, AssertJ, Alβ¦
- Walk through your strategy for stable selectors that survive UI refactors.Senior
Push for `data-test` (or similar) attributes on every interactive element. Treat them as test API β versioned, code-reviewed, never removβ¦
- How would you handle parallel execution of Selenium tests across browsers?Senior
Run TestNG parallel at method/class level with `ThreadLocal<WebDriver>` to keep instances thread-safe. For multi-browser: use TestNG suitβ¦
- How do you debug a Selenium test that fails only in headless mode?Senior
Reproduce locally with `--headless=new`, take screenshots and HTML dumps at each step, capture browser console + network logs, and comparβ¦
- How would you integrate Selenium tests into a Jenkins pipeline with reporting?Senior
Declarative Jenkinsfile with stages: checkout β build β start Grid β run TestNG β publish results. Allure or Extent for reports, JUnit XMβ¦
- Compare a Java/Selenium framework with a JavaScript/Playwright stack β when to choose which?Senior
Pick to match the team's primary language. Java/Selenium fits enterprise teams with Java backends, mature build tooling, and existing Selβ¦
- How do you reduce flakiness in a 500+ test Selenium suite?Senior
Measure first (per-test rerun rate), categorise by cause (waits, data, environment, app bugs), then fix in priority: explicit waits everyβ¦
- How would you migrate a Selenium suite to Playwright incrementally?Senior
Run both suites in parallel during migration. Migrate by feature area, smoke first, regression second. Pick a 'tracer bullet' feature, poβ¦
- How would you set up Selenium Grid 4 in Docker for CI usage?Senior
Docker Compose with a hub container and chrome/firefox node containers, scaled with `--scale chrome=N`. Tests connect via `RemoteWebDriveβ¦
- Walk through how you'd test a feature requiring a specific browser version that's no longer in the official driver library.Senior
Pin the browser binary, find the matching driver from the vendor's download archive, configure the WebDriver with explicit binary + driveβ¦
- How would you justify continued investment in Selenium when newer tools exist?Lead
Frame it in business terms: cost of migration vs cost of staying. If the suite is stable, the team is fluent, and Selenium meets the prodβ¦
- How do you structure mentoring for engineers new to test automation in a Java/Selenium codebase?Lead
Three-layer onboarding: language fundamentals (Java + Maven + JUnit/TestNG), framework patterns (page objects, waits, fixtures), then theβ¦