Exit course
Chapter 1 of 8 Intermediate 5 min read 1 quick check Updated

Selenium Interview Questions

Selenium, Playwright, Cypress, Appium and TestNG interview questions with the answer interviewers want, the follow-up they ask next and red-flag answers.

What you will learn

  1. Selenium Interview Questions
  2. Advanced Selenium Interview Questions
  3. Playwright Interview Questions
  4. Cypress Interview Questions
  5. Appium Interview Questions
  6. TestNG Interview Questions
  7. Scenario and Coding Questions
  8. Knowledge check
On this page
  1. Junior level
  2. Mid level
  3. Senior level
  4. What you'll build / prerequisites

Last reviewed November 2026 against Selenium 4.52, Playwright 1.65, Cypress 16.2, Appium 3.9 and TestNG 7.12.

Most interview-question lists give you a one-line definition to memorise. Interviewers rarely grade on definitions. They grade on whether you know why something works, what breaks in practice, and whether your habits would make their suite better or worse. Every question in this course therefore has three parts: the answer that scores, the follow-up you should expect, and the red-flag answer that quietly ends the interview.

This first chapter covers Selenium fundamentals. The questions are grouped by the level at which they usually come up.

Junior level#

How does Selenium WebDriver actually control a browser?#

Your test calls a language binding (Java, Python, C#, JavaScript, Ruby). The binding sends HTTP requests in the W3C WebDriver format to a browser-specific driver (chromedriver, geckodriver, msedgedriver, safaridriver), and that driver controls the browser through the browser's own automation interface. With a Selenium Grid the same requests go to the Grid first, which forwards them to a node.

  • Follow-up: "What changed in Selenium 4?" The old JSON Wire Protocol is gone; the bindings speak only W3C WebDriver, so capabilities are standardised (browserName, platformName, vendor prefixes like goog:chromeOptions).
  • Red flag: "Selenium injects JavaScript into the page to click things." That was Selenium RC, retired over a decade ago.

Which locator do you reach for first, and why?#

A stable, purpose-built attribute: id, or a dedicated test attribute such as data-testid that developers agree not to change. Then short CSS selectors. XPath when you need something CSS cannot express, such as matching on text or walking up to an ancestor.

driver.findElement(By.id("email"));
driver.findElement(By.cssSelector("[data-testid='checkout-button']"));
driver.findElement(By.xpath("//tr[td[text()='INV-1042']]//button[text()='Pay']"));
  • Follow-up: "The developers won't add test IDs. Now what?" Talk about locating by accessible name or label, and agreeing a convention with the team.
  • Red flag: Copying absolute XPath (/html/body/div[3]/div[2]/...) from DevTools. It breaks on the first layout change.

What is the difference between implicit and explicit waits?#

An implicit wait is a global timeout applied to every findElement call: it only waits for an element to exist. An explicit wait polls for a specific condition, such as visible, clickable or text present, for one action.

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement button = wait.until(ExpectedConditions.elementToBeClickable(By.id("submit")));
button.click();
  • Follow-up: "Can you mix them?" The Selenium documentation warns against it: combining the two can produce unpredictable wait times. Pick explicit waits.
  • Red flag: Thread.sleep(5000) as the fix for timing problems. It is slow when the page is fast and still fails when it is slow.

Mid level#

Which exceptions do you see most, and what does each one tell you?#

  • NoSuchElementException: the locator matched nothing at that moment. Usually a timing issue or a wrong locator.
  • StaleElementReferenceException: you hold a reference to an element the page has since re-rendered. Re-locate it instead of caching it.
  • ElementClickInterceptedException: another element (overlay, cookie banner, sticky header) would receive the click. See how to fix ElementClickInterceptedException.
  • TimeoutException: an explicit wait's condition never became true.

A strong answer adds how you would handle each one; the article on exception handling with Selenium has examples.

  • Red flag: Wrapping every action in try/catch and retrying. That hides real bugs.

How do you work with frames, windows and alerts?#

All three require switching the driver's context.

driver.switchTo().frame("payment-frame");        // name/id, index or WebElement
driver.findElement(By.id("card-number")).sendKeys("4242424242424242");
driver.switchTo().defaultContent();

String original = driver.getWindowHandle();
driver.switchTo().newWindow(WindowType.TAB);      // Selenium 4
driver.get("https://example.com/help");
driver.close();
driver.switchTo().window(original);

new WebDriverWait(driver, Duration.ofSeconds(5))
    .until(ExpectedConditions.alertIsPresent())
    .accept();
  • Follow-up: "A link opens a new tab. How do you switch to it?" Collect getWindowHandles(), pick the handle that is not the original.

A test types the card number inside the payment iframe, then fails with NoSuchElementException on the "Pay now" button, which sits on the main page. What is missing?

After switching into a frame, every lookup searches inside that frame until you switch back. A wait would just time out in the wrong context, and a window switch is for tabs, not frames.

Senior level#

What did Selenium 4 add that changes how you write tests?#

W3C-only communication, Options classes instead of DesiredCapabilities, relative locators (RelativeLocator.with(...).below(...)), newWindow, element screenshots, a rewritten Grid, Selenium Manager (automatic driver management, added in 4.6) and WebDriver BiDi for event-driven features such as console and network listening. The advanced Selenium interview questions chapter covers Grid, BiDi and Selenium Manager in depth.

  • Red flag: Describing Selenium 3 setup (System.setProperty("webdriver.chrome.driver", ...)) as the current way of doing things.

What you'll build / prerequisites#

There is no app to build in this course. You build a repertoire: around 70 questions across eight chapters, each with a short code sample you should be able to write from memory.

  1. Selenium fundamentals (this page)
  2. Advanced Selenium: Grid 4, parallel runs, BiDi, flaky tests, framework design
  3. Playwright, the most detailed chapter
  4. Cypress
  5. Appium
  6. TestNG
  7. Scenario and live-coding questions
  8. Knowledge check

Prerequisites: you have written at least a few UI tests in one language. Code samples use Java for Selenium, Appium and TestNG and TypeScript for Playwright and Cypress.