20 questions · Updated June 2026

Top Selenium Interview Questions and Answers (2026)

Selenium interviews go deep on stability. Most failures aren't about the API — they're about waits, locators and test design. These questions reflect that.

Book a free demo
  1. Q01.What is Selenium WebDriver?

    A browser automation API that drives real browsers via the W3C WebDriver protocol, used for functional UI testing.

  2. Q02.Selenium IDE vs WebDriver vs Grid?

    IDE is a record-and-replay browser extension. WebDriver is the programmatic API. Grid distributes tests across multiple machines and browsers.

  3. Q03.Difference between findElement and findElements?

    `findElement` returns a single WebElement and throws if none found. `findElements` returns a list (possibly empty).

  4. Q04.What are common locator strategies?

    id, name, className, tagName, linkText, partialLinkText, CSS selector and XPath. Prefer data-testid attributes or accessible roles for stability.

  5. Q05.When would you use XPath over CSS selector?

    When you need to traverse up the DOM (parent axes) or match by visible text. CSS is faster and preferred when it works.

  6. Q06.What is the difference between implicit and explicit waits?

    Implicit waits apply globally to every findElement call. Explicit waits use WebDriverWait with expected conditions for a specific element — preferred for predictability.

  7. Q07.Why is Thread.sleep considered bad practice?

    It always waits the full duration, slowing tests, and still fails if the element appears even one millisecond later. Use explicit waits instead.

  8. Q08.What is the Page Object Model?

    A design pattern where each page is wrapped in a class exposing actions and locators. Reduces duplication and makes tests resilient to UI changes.

  9. Q09.How do you handle dropdowns?

    Wrap the element in `Select` and call `selectByVisibleText`, `selectByIndex` or `selectByValue`. For custom dropdowns, click and pick the option element directly.

  10. Q10.How do you handle alerts?

    Use `driver.switch_to.alert` then call `accept()`, `dismiss()` or `send_keys()`.

  11. Q11.How do you handle iframes?

    Switch into the frame with `driver.switch_to.frame(frame)`, perform actions, then switch back with `driver.switch_to.default_content()`.

  12. Q12.How do you handle file uploads?

    Send the absolute file path directly to the file input element via `send_keys`. Don't try to automate the OS dialog.

  13. Q13.What's the difference between getAttribute and getText?

    `getAttribute` returns an HTML attribute value. `getText` returns the visible text content of the element.

  14. Q14.How do you take a screenshot on failure?

    Use `driver.save_screenshot('fail.png')` inside a pytest hook (`pytest_runtest_makereport`) or a TestNG listener.

  15. Q15.What is Selenium Grid?

    A hub-and-node setup that distributes tests across browsers and machines, enabling parallel cross-browser execution.

  16. Q16.How do you run tests in headless mode?

    Pass the appropriate option to your browser, e.g. ChromeOptions with `--headless=new`. Useful for CI environments.

  17. Q17.How do you integrate Selenium with CI?

    Run tests via pytest/TestNG in a Docker container with a Selenium image, then publish JUnit reports to Jenkins, GitHub Actions or GitLab CI.

  18. Q18.What is a stale element exception?

    It occurs when an element you cached is no longer attached to the DOM. Re-locate it before interacting.

  19. Q19.How do you scale Selenium tests?

    Parallelise with pytest-xdist or TestNG, run in Selenium Grid or a cloud service like BrowserStack, and keep tests independent so they can run in any order.

  20. Q20.What is the difference between assert and verify?

    Assert stops the test on failure. Verify (soft assert) records the failure and continues — useful for checking multiple things in one test.

Interview prep support

Get 1:1 prep on Selenium

Our mentors will reach out with a personalised prep plan, mock interview slots and target-company question banks.