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.

Level

Showing 37 of 37 questions

  1. 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…

  2. 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…

  3. 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…

  4. 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…

  5. 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…

  6. 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…

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

  8. 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…

  9. 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…

  10. 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…

  11. 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…

  12. 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…

  13. 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…

  14. 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…

  15. 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().…

  16. 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…

  17. 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…

  18. 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…

  19. 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.…

  20. 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…

  21. 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…

  22. 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("…

  23. 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…

  24. 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…

  25. 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…

  26. 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…

  27. 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…

  28. 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…

  29. 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…

  30. 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…

  31. 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…

  32. 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…

  33. 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…

  34. 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…

  35. 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…

  36. 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…

  37. 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…