Selenium interview questions — Medium
502 medium-level Selenium questions from our Automation Testing bank, each with the correct answer and an explanation of why it is correct.
What this covers
Selenium appears throughout Automation Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.
20 example questions
1. "Configure browser-specific settings such as headless mode" — in Selenium, this describes which of the following?
- A. Driver.navigate().back().
- B. Driver.close().
- C. Desired capabilities / Options classes.correct
- D. Window handles.
Why: desired capabilities / Options classes: Configure browser-specific settings such as headless mode.
2. "Explicit wait that polls until an ExpectedCondition is satisfied" — in Selenium, this describes which of the following?
- A. TakesScreenshot.
- B. GetAttribute("value").
- C. WebDriverWait.correct
- D. Window handles.
Why: WebDriverWait: Explicit wait that polls until an ExpectedCondition is satisfied.
3. "Switches control to a JavaScript alert/confirm/prompt" — in Selenium, this describes which of the following?
- A. GetAttribute("value").
- B. Driver.findElement(By.id(...)).
- C. Driver.switchTo().alert().correct
- D. Driver.navigate().back().
Why: driver.switchTo().alert(): Switches control to a JavaScript alert/confirm/prompt.
4. While onboarding a junior QA, you explain: Which Selenium wait polls the DOM until a condition is met, throwing only on timeout?
- A. Thread.sleep().
- B. Implicit wait.
- C. Explicit wait (WebDriverWait).correct
- D. Page load timeout.
Why: Explicit waits poll until a condition is true or the timeout elapses.
5. "Condition that waits until an element is visible and enabled" — in Selenium, this describes which of the following?
- A. GetAttribute("value").
- B. Driver.findElement(By.id(...)).
- C. ExpectedConditions.elementToBeClickable.correct
- D. By.cssSelector.
Why: ExpectedConditions.elementToBeClickable: Condition that waits until an element is visible and enabled.
6. "Returns the first element matching the ID locator or throws NoSuchElementException" — in Selenium, this describes which of the following?
- A. Driver.findElement(By.id(...)).correct
- B. Driver.quit().
- C. Desired capabilities / Options classes.
- D. Window handles.
Why: driver.findElement(By.id(...)): Returns the first element matching the ID locator or throws NoSuchElementException.
7. "Identifiers used to switch between browser tabs/windows" — in Selenium, this describes which of the following?
- A. Driver.findElement(By.id(...)).
- B. By.cssSelector.
- C. Window handles.correct
- D. Driver.close().
Why: window handles: Identifiers used to switch between browser tabs/windows.
8. Which statement correctly describes Selenium?
- A. Driver.switchTo().frame() is required before interacting with elements inside an iframe.correct
- B. Selenium natively includes a built-in test runner and assertion library.
- C. FindElement returns null instead of throwing when no element matches.
- D. XPath is always faster than CSS selectors in every browser.
Why: Elements in iframes are invisible to the default browsing context.
9. "Simulates the browser back button" — in Selenium, this describes which of the following?
- A. TakesScreenshot.
- B. Desired capabilities / Options classes.
- C. Driver.close().
- D. Driver.navigate().back().correct
Why: driver.navigate().back(): Simulates the browser back button.
10. Identify the accurate statement about Selenium:
- A. A StaleElementReferenceException means the element locator syntax is invalid.
- B. The Page Object Model separates page structure from test logic to improve maintainability.correct
- C. FindElement returns null instead of throwing when no element matches.
- D. Implicit and explicit waits are recommended to be combined for maximum stability.
Why: POM keeps locators in one place so UI changes require fewer edits.
11. "Closes only the current window" — in Selenium, this describes which of the following?
- A. Desired capabilities / Options classes.
- B. Driver.close().correct
- C. Window handles.
- D. ExpectedConditions.elementToBeClickable.
Why: driver.close(): Closes only the current window.
12. Which of the following statements about Selenium is TRUE?
- A. Selenium Manager (bundled since 4.6) automatically downloads matching browser drivers.correct
- B. Selenium Manager must be installed as a separate pip/npm package.
- C. FindElement returns null instead of throwing when no element matches.
- D. XPath is always faster than CSS selectors in every browser.
Why: Selenium Manager removed the need to manage ChromeDriver manually.
13. "Locator strategy using CSS selector syntax" — in Selenium, this describes which of the following?
- A. TakesScreenshot.
- B. Driver.switchTo().alert().
- C. Driver.navigate().back().
- D. By.cssSelector.correct
Why: By.cssSelector: Locator strategy using CSS selector syntax.
14. In Selenium, which of the following is described as: "Explicit wait that polls until an ExpectedCondition is satisfied"?
- A. Driver.navigate().back().
- B. By.cssSelector.
- C. WebDriverWait.correct
- D. Driver.findElement(By.id(...)).
Why: WebDriverWait: Explicit wait that polls until an ExpectedCondition is satisfied.
15. Which Selenium concept matches this description: "Configure browser-specific settings such as headless mode"?
- A. Driver.findElement(By.id(...)).
- B. WebDriverWait.
- C. GetAttribute("value").
- D. Desired capabilities / Options classes.correct
Why: desired capabilities / Options classes: Configure browser-specific settings such as headless mode.
16. Which Selenium concept matches this description: "Explicit wait that polls until an ExpectedCondition is satisfied"?
- A. WebDriverWait.correct
- B. GetAttribute("value").
- C. Window handles.
- D. TakesScreenshot.
Why: WebDriverWait: Explicit wait that polls until an ExpectedCondition is satisfied.
17. Which Selenium concept matches this description: "Returns the first element matching the ID locator or throws NoSuchElementException"?
- A. By.cssSelector.
- B. Desired capabilities / Options classes.
- C. Driver.findElement(By.id(...)).correct
- D. GetAttribute("value").
Why: driver.findElement(By.id(...)): Returns the first element matching the ID locator or throws NoSuchElementException.
18. In Selenium, which of the following is described as: "Reads the current value attribute of an element"?
- A. TakesScreenshot.
- B. WebDriverWait.
- C. GetAttribute("value").correct
- D. By.cssSelector.
Why: getAttribute("value"): Reads the current value attribute of an element.
19. In the context of Selenium, which of the following is a correct statement?
- A. XPath is always faster than CSS selectors in every browser.
- B. Implicit and explicit waits are recommended to be combined for maximum stability.
- C. Selenium Manager (bundled since 4.6) automatically downloads matching browser drivers.correct
- D. Selenium Manager must be installed as a separate pip/npm package.
Why: Selenium Manager removed the need to manage ChromeDriver manually.
20. Which Selenium concept matches this description: "Identifiers used to switch between browser tabs/windows"?
- A. Desired capabilities / Options classes.
- B. Window handles.correct
- C. ExpectedConditions.elementToBeClickable.
- D. TakesScreenshot.
Why: window handles: Identifiers used to switch between browser tabs/windows.