Skip to content
TryHired.
Interview prep · Technical · checked against the official docs

Selenium interview questions: answers checked against the docs

The browser automation questions QA and SDET roles get, answered in plain words and checked against the official Selenium documentation.

Updated Nov 17, 2026 · Facts checked against the official documentation · questions: TryHired
Quick answer

Selenium interviews cover how WebDriver controls a browser, locator strategies, implicit versus explicit waits and flaky tests, stale elements, the Page Object Model, frames, windows and alerts, the Actions API, Selenium Grid, page load strategies, WebDriver BiDi and test-suite design. Below are 12 questions; each answer lists the selenium.dev pages it was checked against.

Basic

Basic Selenium interview questions

Advice

Basic1. What is Selenium WebDriver, and how does it talk to a browser?

WebDriver is an API for controlling a browser the way a user would: open pages, find elements, click and type. Your test code sends commands through a language binding (Java, Python, C#, JavaScript and others) to a driver such as chromedriver or geckodriver, and the driver controls the browser. The WebDriver protocol is a W3C standard, which is why the same test can drive different browsers. With Selenium Manager, current Selenium releases can locate or download the right driver for you.

Checked against: Selenium docs: Selenium Manager, Selenium docs: components, Selenium docs: WebDriver

Basic2. Which locator strategies does Selenium support, and which should you prefer?

Selenium supports eight traditional strategies: id, name, class name, tag name, link text, partial link text, CSS selector and XPath, plus relative locators. Prefer a stable id, name or a dedicated test attribute; use CSS selectors for the rest. Avoid long absolute XPath expressions tied to page layout, because any change to the structure breaks them.

Python snippet · illustrative, not run on this page
from selenium.webdriver.common.by import By

driver.find_element(By.ID, "email")
driver.find_element(By.CSS_SELECTOR, "[data-test=submit]")
driver.find_elements(By.XPATH, "//table[@id='jobs']//tr")

Checked against: Selenium docs: locators

Basic3. What is the difference between implicit and explicit waits?

An implicit wait is a global setting: every element lookup retries for up to the given time before failing. An explicit wait (WebDriverWait) waits for a specific condition in one place, such as an element becoming clickable or text appearing, which is more precise. The Selenium docs warn not to mix the two, because combining them can make wait times unpredictable. Fixed sleeps make tests slow and still flaky.

Python snippet · illustrative, not run on this page
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

button = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.ID, "save"))
)
button.click()

Checked against: Selenium docs: waits

Basic4. Why are Selenium tests flaky, and how do you fix them?

Usually because the test and the page race: the script acts before the page is ready, and sometimes the page wins. Fix it with explicit waits for real conditions, stable locators, independent test data, and clean browser sessions per test. Retrying a whole failing test hides the problem rather than fixing it.

Checked against: Selenium docs: waits

Intermediate

Intermediate Selenium interview questions

Advice

Intermediate5. What is a StaleElementReferenceException, and how do you handle it?

It happens when you use an element reference you found earlier but the page has since replaced that element, for example after a re-render or navigation. Locate the element again just before using it, or wait for the condition you need; do not store element references across page updates. NoSuchElementException, by contrast, means the element could not be found at the moment you searched.

Checked against: Selenium docs: understanding common errors

Intermediate6. What is the Page Object Model?

A page object is a class that represents a page or component: it holds the locators and offers methods for what a user can do there, such as log_in(). Tests call those methods, so when the UI changes, you fix one class instead of every test. The Selenium docs recommend keeping assertions out of page objects, in the tests.

Python snippet · illustrative, not run on this page
class LoginPage:
    def __init__(self, driver):
        self.driver = driver
    def log_in(self, email, password):
        self.driver.find_element(By.ID, "email").send_keys(email)
        self.driver.find_element(By.ID, "password").send_keys(password)
        self.driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
        return DashboardPage(self.driver)

Checked against: Selenium docs: page object models

Intermediate7. How do you work with iframes, new windows and alerts?

Each needs an explicit switch. For an iframe, switch into the frame before finding elements inside it, then switch back to the default content. For a new tab or window, read the window handles and switch to the new one. For JavaScript alerts, confirms and prompts, switch to the alert, read its text, then accept or dismiss it; a confirm box adds a cancel option.

Python snippet · illustrative, not run on this page
driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR, "iframe#payment"))
# ... work inside the frame ...
driver.switch_to.default_content()

original = driver.current_window_handle
for handle in driver.window_handles:
    if handle != original:
        driver.switch_to.window(handle)

alert = WebDriverWait(driver, 5).until(EC.alert_is_present())
alert.accept()

Checked against: Selenium docs: alerts, Selenium docs: frames, Selenium docs: windows

Intermediate8. When do you need the Actions API?

For interactions that a single click or send_keys cannot express: hovering to open a menu, drag and drop, right-click, holding a key while clicking, or precise pointer movements. ActionChains (in Python) builds a sequence of low-level input actions and performs them together.

Python snippet · illustrative, not run on this page
from selenium.webdriver.common.action_chains import ActionChains

menu = driver.find_element(By.ID, "account")
ActionChains(driver).move_to_element(menu).click(driver.find_element(By.ID, "logout")).perform()

Checked against: Selenium docs: Actions API

Advanced

Advanced Selenium interview questions

Advice

Advanced9. What is Selenium Grid, and when would you use it?

Grid runs WebDriver tests on remote machines: your test talks to the Grid, which routes commands to a node with the requested browser. Use it to run tests in parallel and across browser versions and operating systems. Cloud testing services offer the same model as a hosted service.

Python snippet · illustrative, not run on this page
options = webdriver.ChromeOptions()
driver = webdriver.Remote(command_executor="http://grid.example.internal:4444", options=options)

Checked against: Selenium docs: Grid

Advanced10. What does the page load strategy option control?

It decides when driver.get() returns. normal, the default, waits for the whole page, including images and stylesheets, to finish loading; eager returns once the HTML is parsed (DOMContentLoaded); none returns as soon as the initial page is received. eager can speed up tests, but then your code must wait for whatever it needs.

Python snippet · illustrative, not run on this page
options = webdriver.ChromeOptions()
options.page_load_strategy = "eager"
driver = webdriver.Chrome(options=options)

Checked against: Selenium docs: browser options

Advanced11. What is WebDriver BiDi?

Classic WebDriver is one-directional: the test sends a command and waits for a reply. WebDriver BiDi, developed by the Selenium team with the browser vendors, adds two-way communication, so the browser can stream events to the test, such as console messages, network activity and JavaScript errors. It replaces many uses of the Chrome-only DevTools Protocol with a cross-browser standard.

Checked against: Selenium docs: BiDi

Advanced12. How would you design a maintainable Selenium test suite?

Keep tests independent and runnable in any order, each with its own data and browser session; wrap pages in page objects; use explicit waits; keep locators stable by agreeing on test attributes with developers; run in parallel on a Grid or a cloud service in CI; and capture screenshots and logs on failure. Keep the bulk of the coverage in faster unit and API tests, and use browser tests for the critical user journeys.

Checked against: Selenium docs: Grid, Selenium docs: page object models, Selenium docs: waits

Practice

How to practice with this page

Advice
  • Write each wait as an explicit condition, never a sleep.
  • Build a small page-object suite for a public demo site.
  • Explain one flaky test you fixed and the root cause.
  • Practice in the language the team uses, such as Java or Python.
Next

Related interview prep and tools

Disclosure: TryHired makes HIRED, a paid job-search program, so we have a conflict of interest when we mention it. This question bank is free, with no TryHired signup.

FAQ

Questions people ask

What Selenium topics come up often in interviews?
Locators, waits and flaky tests, the Page Object Model, frames, windows and alerts, the Actions API, Grid and parallel runs, framework design with TestNG, JUnit or pytest, and for senior roles, CI integration and reporting.
Is Selenium better than Playwright or Cypress?
They make different trade-offs: Selenium supports the widest range of languages and browsers through the W3C WebDriver standard, while Playwright and Cypress add built-in auto-waiting and other conveniences.
Were these snippets run?
No. Selenium and its drivers are not installed on the build machine, so the Python snippets are illustrations and no output is shown. They assume an existing driver object and the usual imports.
Method

How this page is built

TryHired wrote these questions and answers. Statements about the technology were checked against the official documentation pages listed below, saved when the page was built (2026-11-17). The code snippets are short illustrations and were not run on this page. The question list is general practice: it does not predict what a particular employer will ask.

What this page can't tell you
  • Interviewers ask different questions for different roles and levels.
  • Answers are short explanations, not complete references.
  • No Selenium code was run on this page; the Python snippets assume an existing driver and the usual imports. APIs follow the current selenium.dev documentation.
Sources
  1. Selenium docs: Actions API (read 2026-11-17)
  2. Selenium docs: alerts (read 2026-11-17)
  3. Selenium docs: BiDi (read 2026-11-17)
  4. Selenium docs: understanding common errors (read 2026-11-17)
  5. Selenium docs: frames (read 2026-11-17)
  6. Selenium docs: Grid (read 2026-11-17)
  7. Selenium docs: locators (read 2026-11-17)
  8. Selenium docs: Selenium Manager (read 2026-11-17)
  9. Selenium docs: browser options (read 2026-11-17)
  10. Selenium docs: components (read 2026-11-17)
  11. Selenium docs: page object models (read 2026-11-17)
  12. Selenium docs: waits (read 2026-11-17)
  13. Selenium docs: WebDriver (read 2026-11-17)
  14. Selenium docs: windows (read 2026-11-17)