Scenario-Based Selenium Interview Questions (2027)
66 scenario-based Selenium 4 interview questions with answers: waits, Selenium Manager, Grid 4, relative locators, shadow DOM, BiDi, flaky tests and CI.
Scenario-based Selenium interview questions test whether you can keep browser tests stable when real pages misbehave: slow AJAX content, pop-ups, iframes, new tabs, shadow DOM, stale elements and tests that pass locally but fail in CI. Interviewers expect Selenium 4 answers that use explicit waits, Selenium Manager, Grid 4, WebDriver BiDi and the Page Object Model.
This page has 66 numbered questions with direct answers, grouped by experience level and followed by 19 real-world scenarios. Code samples use Python because it is short to read; the Java method names are given in the text where they differ. Commands and APIs were checked against the official Selenium documentation at selenium.dev in November 2026, when the current release was Selenium 4.52.0 (29 October 2026).
Key takeaways
- Use explicit waits (
WebDriverWaitwith an expected condition) for anything dynamic. The Selenium docs warn against mixing implicit and explicit waits because the timeouts can add up unpredictably. - Selenium Manager has shipped with every release since Selenium 4.6. It finds or downloads the right driver, and it can also download Chrome, Firefox and Edge when they are missing.
- Grid 4 is built from a Router, Distributor, Session Map, New Session Queue, Event Bus and Nodes. It runs as standalone, hub and node, or fully distributed.
- WebDriver BiDi is the W3C, cross-browser replacement for the Chrome DevTools Protocol (CDP). Selenium describes its CDP support as temporary.
- Most flaky tests come from timing, shared test data, or brittle locators. Fix the cause before adding retries.
- For scenario questions, explain the symptom, how you would confirm the cause, the fix, and how you would stop it recurring.
How to use this guide
Read the section that matches your experience, then practise the scenarios aloud. If your interview also covers general Selenium theory, our 100+ Selenium interview questions post covers the basics in more depth, and the CI/CD pipeline examples guide shows where UI tests sit in a full delivery pipeline.
| Your experience | Read first | Then practise |
|---|---|---|
| Fresher or manual tester moving to automation | Questions 1 to 15 | Write one login test with explicit waits and a screenshot on failure |
| 2 to 5 years in automation | Questions 16 to 35 | Build a small Page Object Model framework and run it in parallel |
| Senior SDET or test lead | Questions 36 to 47 | Run the suite on Grid 4 in Docker from a CI pipeline |
| Everyone with work experience | Questions 48 to 66 (scenarios) | Explain each scenario in under two minutes |
Selenium interview questions for freshers
1. What is Selenium and what are its main parts?
Selenium is an open-source project for automating web browsers. It has three main parts: WebDriver, the library you call from Java, Python, C#, JavaScript or Ruby to drive a browser; Selenium Grid, which runs tests on remote machines and in parallel; and Selenium IDE, a browser extension that records and plays back simple tests. Most interview questions are about WebDriver and Grid.
2. What changed in Selenium 4 compared with Selenium 3?
Selenium 4 talks to browsers only through the W3C WebDriver standard, so the old JSON Wire Protocol is gone. It also added relative locators, a direct way to open a new tab or window, element screenshots, shadow DOM access through getShadowRoot(), a redesigned Grid, Selenium Manager (from 4.6), CDP access for Chromium browsers and, more recently, WebDriver BiDi support.
3. You start a new project. Do you still need to download chromedriver or add WebDriverManager?
Usually no. Selenium Manager is bundled with Selenium and runs automatically when you create a driver and no driver is found. It detects the installed browser version, downloads the matching driver and caches it under ~/.cache/selenium by default. A driver you place on the PATH yourself still takes priority.
from selenium import webdriver
driver = webdriver.Chrome() # Selenium Manager resolves chromedriver if needed
driver.get("https://www.selenium.dev")
print(driver.title)
driver.quit()
4. Which locator do you try first, and why?
Use a stable, unique attribute first: id, a dedicated test attribute such as data-testid through a CSS selector, or name. Use XPath when you need to locate by visible text or move from a child to a parent. Avoid absolute XPaths and auto-generated class names because they break whenever the layout changes.
| Locator | Python example | When to use |
|---|---|---|
| id | By.ID, "email" | Unique and stable ids |
| name | By.NAME, "q" | Form fields |
| CSS selector | By.CSS_SELECTOR, "[data-testid='save']" | Test attributes, combined attributes |
| XPath | By.XPATH, "//button[text()='Save']" | Text matching, walking up the DOM |
| link text | By.LINK_TEXT, "Sign in" | Anchor links with fixed text |
| class name, tag name, partial link text | By.CLASS_NAME, "error" | Rarely unique; use with care |
5. What is the difference between findElement and findElements when nothing matches?
findElement (find_element in Python) throws NoSuchElementException if no element matches. findElements returns an empty list. Use findElements when you want to check that something is absent without catching an exception, for example to assert that an error banner is not shown.
6. What are implicit, explicit and fluent waits?
An implicit wait is a session-wide setting that makes every element lookup retry for up to the given time; its default is 0. An explicit wait polls for one specific condition, such as an element becoming clickable. A fluent wait is an explicit wait where you also set the polling interval and the exceptions to ignore. Prefer explicit waits, and do not combine them with an implicit wait.
| Wait | Scope | Typical use |
|---|---|---|
| Implicit | Every lookup in the session | Simple scripts; avoid in frameworks |
Explicit (WebDriverWait) | One condition | Visibility, clickability, text, URL, alert present |
Fluent (FluentWait in Java; poll_frequency and ignored_exceptions in Python) | One condition, custom polling | Slow or noisy elements |
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, timeout=10, poll_frequency=0.3)
save = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "[data-testid='save']")))
save.click()
7. Why should you avoid Thread.sleep or time.sleep in tests?
A fixed sleep always waits the full time, even when the page is ready early, so it slows the suite. When the page is slower than the sleep, the test still fails. An explicit wait returns as soon as the condition is true and fails with a clear timeout message when it is not.
8. How do you handle a JavaScript alert or confirm pop-up?
Wait for the alert, switch to it, read its text if needed, then accept or dismiss it. In Java this is driver.switchTo().alert().
alert = WebDriverWait(driver, 5).until(EC.alert_is_present())
print(alert.text)
alert.accept() # or alert.dismiss()
An HTML modal dialog built with a div is not an alert. Treat it as normal page elements.
9. How do you work with an element inside an iframe?
Switch into the frame first, interact, then switch back. You can switch by WebElement (the most flexible option according to the Selenium docs), by name or id, or by zero-based index. Wait for the frame with frame_to_be_available_and_switch_to_it if it loads late.
WebDriverWait(driver, 10).until(
EC.frame_to_be_available_and_switch_to_it((By.ID, "payment-frame")))
driver.find_element(By.NAME, "cardholder").send_keys("Test User")
driver.switch_to.default_content() # back to the top-level page
10. How do you open and switch between tabs or windows?
Each window has a handle that stays the same for the session. Save the current handle, trigger or open the new window, then switch to the handle that is not the original. Selenium 4 can open one directly with driver.switch_to.new_window("tab") (Java: driver.switchTo().newWindow(WindowType.TAB)). After closing a window, switch to a valid handle or you get a no such window error.
11. How do you select a value from a dropdown?
For a native HTML select element, use the Select class with select_by_visible_text, select_by_value or select_by_index. Many modern dropdowns are built from div and li elements, and Select does not work on them; click the control, wait for the option list, then click the option by its text.
12. What is the difference between close() and quit()?
close() closes the current window only. quit() closes every window and ends the WebDriver session, which also frees the slot on a Grid node. Always call quit() in teardown, even when the test fails, or you leak browser processes and Grid sessions.
13. How do you capture a screenshot when a test fails?
Call driver.save_screenshot() (Java: TakesScreenshot) from a failure hook: a pytest fixture or hook, a TestNG listener, or a JUnit extension. Selenium 4 can also screenshot a single element with element.screenshot("file.png"). Attach the image and the page URL to the test report.
14. How do you upload a file?
Send the absolute file path to the input type="file" element with send_keys; do not click the button, because the operating system dialog that opens is outside the browser and Selenium cannot drive it. When the test runs on a remote Grid, the Java and Python bindings can use a LocalFileDetector so the file is sent to the node.
15. What can Selenium not do?
Selenium automates the browser only. It cannot drive operating system dialogs, solve CAPTCHAs (they exist to stop automation), read OTPs from a phone, or measure load and performance. Use API or unit tests for business logic, a load testing tool for performance, and Appium for native mobile apps.
Selenium interview questions for 2 to 5 years of experience
16. What causes StaleElementReferenceException and how do you fix it?
The element you stored has been removed from the DOM or re-rendered, often after an AJAX refresh, a page navigation or a framework re-render. Fix it by locating the element again just before using it, by waiting for the refresh to finish (for example EC.staleness_of(old_element)), and by having page objects return locators or fresh lookups instead of cached elements.
17. A click throws ElementClickInterceptedException. What do you do?
Another element, usually a spinner, cookie banner, sticky header or modal backdrop, is on top of the target. Wait for the overlay to disappear with EC.invisibility_of_element_located, close the banner, or scroll the element into a clear area. Use a JavaScript click only as a last resort, because it bypasses the overlay a real user would also hit.
18. What does ElementNotInteractableException mean?
The element exists in the DOM but cannot receive the action, for example because it is hidden, has zero size, is disabled or sits behind a collapsed section. Wait for visibility or clickability, open the section that contains it, or check whether there are two matching elements and your locator picked the hidden one.
19. What are relative locators and when do you use them?
Relative locators, added in Selenium 4, find an element by its position relative to another element: above, below, to the left of, to the right of, or near. They help when a field has no stable attribute but sits next to a stable label. They depend on rendered layout, so a responsive layout change can break them.
from selenium.webdriver.support.relative_locator import locate_with
email = driver.find_element(
locate_with(By.TAG_NAME, "input").above({By.ID: "password"}))
In Java the same call is RelativeLocator.with(By.tagName("input")).above(By.id("password")).
20. How do you automate elements inside a shadow DOM?
Find the shadow host, get its shadow root, and search inside it. Selenium 4 supports this natively (getShadowRoot() in Java, shadow_root in Python), so you no longer need JavaScript workarounds. Inside a shadow root, use CSS selectors; XPath is not supported there.
host = driver.find_element(By.CSS_SELECTOR, "custom-checkbox-element")
root = host.shadow_root
root.find_element(By.CSS_SELECTOR, "input[type=checkbox]").click()
21. Element ids change on every page load. How do you locate the element?
Ask the developers for a stable test attribute such as data-testid; it is the cheapest long-term fix. Until then, use attributes that do not change (name, aria-label, placeholder), partial matches such as [id^='user-'], or XPath anchored on visible text or a nearby label. Avoid index-based locators.
22. What is the Page Object Model and what belongs in a page object?
The Page Object Model puts each page or component in a class that holds its locators and the actions a user can take, such as login(user, password). Tests call those methods and hold the assertions. When the UI changes, you update one class instead of every test. Keep assertions and test data out of page objects, and return the next page object from navigation methods.
class LoginPage:
EMAIL = (By.ID, "email")
PASSWORD = (By.ID, "password")
SUBMIT = (By.CSS_SELECTOR, "[data-testid='login']")
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(driver, 10)
def login(self, email, password):
self.wait.until(EC.visibility_of_element_located(self.EMAIL)).send_keys(email)
self.driver.find_element(*self.PASSWORD).send_keys(password)
self.driver.find_element(*self.SUBMIT).click()
return DashboardPage(self.driver)
23. What is PageFactory and should you use it?
PageFactory is a Java helper that fills @FindBy fields in a page object with lazy proxies. It works, but the proxies can still go stale on pages that re-render, and the annotations hide when lookups happen. Many teams now prefer plain By locators with explicit waits, as in the example above. Either answer is fine if you explain the trade-off.
24. How do you run the same test with many data sets?
Use the test runner's parameterisation: @pytest.mark.parametrize in pytest, @DataProvider in TestNG, or @ParameterizedTest in JUnit 5. Read the data from CSV, JSON or a test data service. Keep each data row independent so rows can run in parallel and a failure points to one input.
25. How do you run tests in parallel safely?
Run them with the runner's parallel mode (pytest-xdist -n 4, TestNG parallel="methods" with a thread count, or JUnit 5 parallel execution) and give every test its own driver. In Java, keep the driver in a ThreadLocal; never share a static driver. Each test also needs its own data, such as a unique user or order, so tests do not change each other's state.
26. What changes when you run Chrome headless?
The browser runs without a visible window, which suits CI agents. Add --headless=new to Chrome options. Set an explicit window size (for example --window-size=1920,1080), because the default headless viewport can be smaller and hide elements behind a responsive menu. Fonts, downloads and GPU features can also differ from a headed run.
27. What is page load strategy?
It controls when driver.get() returns. normal (the default) waits for the full load event, eager returns when the DOM is ready and does not wait for images and stylesheets, and none returns immediately. eager can speed up pages with heavy assets, but you then rely on explicit waits for the elements you need.
28. When is it acceptable to use JavaScriptExecutor?
Use it for things WebDriver has no direct command for: scrolling to a position, reading a value from localStorage, or setting up test state. Avoid it for clicks and typing in functional tests, because it skips the checks a real user hits (visibility, overlays, disabled state) and can hide real bugs.
29. How do you perform hover, drag and drop, or keyboard shortcuts?
Use the Actions API (ActionChains in Python). Chain the steps, then call perform().
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
menu = driver.find_element(By.ID, "products")
ActionChains(driver).move_to_element(menu).perform()
ActionChains(driver).drag_and_drop(source, target).perform()
ActionChains(driver).key_down(Keys.CONTROL).send_keys("a").key_up(Keys.CONTROL).perform()
30. How do you avoid logging in through the UI in every test?
Log in once through an API or a single UI test, then reuse the session: add the session cookie with driver.add_cookie() after opening any page on the same domain, or set a token in local storage. Keep one test that covers the real login form so you do not lose coverage of it.
31. The test environment uses a self-signed certificate. How do you get past the warning page?
Set the W3C capability acceptInsecureCerts to true in the browser options (options.accept_insecure_certs = True in Python). Use it only for test environments; production checks should keep certificate validation on.
32. How do you test a file download?
Set browser preferences so files go to a known folder without a prompt (for Chrome, download.default_directory and download.prompt_for_download), trigger the download, then poll the folder until the file appears and its partial-download extension is gone. On a remote Grid the file lands on the node, so either use Grid's managed downloads feature or verify the download URL with an HTTP client instead.
33. How do you handle an HTTP basic authentication prompt?
The prompt is a browser dialog, so you cannot type into it with WebDriver. Options are a network authentication handler (Java's HasAuthentication interface on Chromium browsers, or a BiDi network handler where your binding supports it), passing credentials in the URL where the browser still allows it, or disabling basic auth in the test environment.
34. How do you report test results?
Produce a machine-readable result (JUnit XML) for the CI server and a human-readable report such as Allure, pytest-html or Extent Reports. Each failure should carry the screenshot, the page URL, the browser and version, and the browser console log. Publish the report as a CI artifact so anyone can open it.
35. How do you plan cross-browser testing?
Run the full suite on the browser most users have and a smaller smoke set on the others (Firefox, Edge, Safari). Parameterise the browser through configuration, not code, and run the matrix on Grid or a cloud provider. Safari needs safaridriver on macOS, so plan macOS capacity for it.
Senior Selenium interview questions
36. Explain the Selenium Grid 4 architecture.
Grid 4 is split into components that can run together or separately. The Router is the entry point for all requests. The Distributor tracks registered Nodes and their capabilities and assigns new sessions. The Session Map links each session id to its Node. The New Session Queue holds new session requests in FIFO order. The Event Bus carries messages between components. Nodes own the browser slots and run the commands.
37. What are the Grid 4 deployment modes and when do you use each?
| Mode | Command | Use when |
|---|---|---|
| Standalone | java -jar selenium-server-<version>.jar standalone | One machine, local runs, a CI job with its own browser |
| Hub and node | ... hub and ... node --hub http://<hub-ip>:4444 | A few machines with different browsers or operating systems |
| Distributed | event-bus, sessionqueue, sessions, distributor, router, node | Large grids where components must scale or fail separately |
The Router listens on port 4444 by default and a Node on 5555. Grid 4 needs Java 11 or later.
38. How do you run Selenium Grid in Docker or Kubernetes?
Use the official docker-selenium images. A standalone browser container is enough for a single CI job; give it extra shared memory, because Chrome crashes with the small Docker default.
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:latest
For shared grids, the project publishes a Helm chart for Kubernetes, which can scale browser nodes with the queue length. Pin image tags to a version in CI rather than using latest, so a browser upgrade does not change results overnight.
39. What is WebDriver BiDi and how is it different from CDP?
WebDriver BiDi is a W3C protocol that adds a WebSocket connection to WebDriver, so the browser can push events (console messages, network requests, JavaScript errors) to your test while it runs. CDP, the Chrome DevTools Protocol, does similar things but only for Chromium browsers and without a stable API. Selenium calls BiDi the cross-browser replacement for CDP, says CDP support is temporary, and only supports the three most recent Chrome versions through CDP.
| WebDriver BiDi | CDP | |
|---|---|---|
| Standard | W3C | Chrome-specific |
| Browsers | Cross-browser by design | Chromium only |
| API stability | Intended to be stable | Changes with browser versions |
| Selenium direction | Being built out | Pages being phased out |
40. How do you capture browser console errors during a test?
Enable BiDi in the browser options (options.enable_bidi = True in Python, enableBidi() in Java), then subscribe to log events and fail or warn the test when JavaScript errors appear. Attach the collected messages to the report. On older setups, Chromium's logging preferences or CDP did the same job for Chrome only.
41. How would you design a Selenium framework from scratch?
Keep it in layers: a driver factory that reads browser, headless and Grid URL from configuration; page objects or component objects; a thin layer of business actions; tests with assertions; and shared utilities for waits, test data and reporting. Add parallel execution, screenshots and logs on failure, tagging for smoke and regression sets, and a single command that CI can run. Keep the framework small enough that a new team member can follow one test end to end.
42. What is your strategy for flaky tests?
Measure first: track pass rates per test over many runs. Quarantine tests that flake so they stop blocking merges, then fix the cause. The usual causes are missing waits, shared or leftover test data, test order dependence, brittle locators and unstable environments. Allow at most one automatic retry (for example pytest-rerunfailures), and report retried passes so flakiness stays visible.
43. How do you manage test data for UI tests?
Create the data each test needs through APIs or database seeding before the test, use unique values (a timestamp or UUID in names and emails), and clean up afterwards or use disposable environments. Never depend on records another test created. Keep secrets such as passwords in the CI secret store, not in the repository.
44. Where do Selenium tests fit in the test pyramid?
At the top. UI tests are the slowest and most fragile layer, so keep them for user journeys that only make sense end to end, such as login, checkout and search. Test validation rules and calculations with unit and API tests. Our guide on which testing types to automate first in CI goes through this order.
45. How does Selenium compare with Playwright and Cypress?
| Selenium | Playwright | Cypress | |
|---|---|---|---|
| Protocol | W3C WebDriver, plus BiDi | Own protocol to bundled browsers | Runs inside the browser |
| Languages | Java, Python, C#, JavaScript, Ruby | JavaScript/TypeScript, Python, Java, .NET | JavaScript/TypeScript |
| Waiting | Explicit waits you write | Auto-waiting built in | Auto-retrying commands |
| Remote and parallel | Selenium Grid and cloud grids | Built-in workers | Parallel runs through its cloud service or CI splitting |
A good answer says Selenium suits teams that need many languages, real branded browsers and an existing Grid, and that the newer tools trade some of that flexibility for built-in waiting.
46. How do you run Selenium tests in a CI pipeline?
Start a browser or Grid as part of the job, point the tests at it through an environment variable, run the suite, and publish JUnit XML plus screenshots even when tests fail. A GitHub Actions example with a Selenium container as a service:
name: ui-tests
on: [push]
jobs:
selenium:
runs-on: ubuntu-latest
services:
selenium:
image: selenium/standalone-chrome:latest
ports:
- 4444:4444
options: --shm-size=2g
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- run: pytest -n 4 --junitxml=results.xml
env:
SELENIUM_REMOTE_URL: http://localhost:4444
- uses: actions/upload-artifact@v4
if: always()
with:
name: ui-test-results
path: |
results.xml
screenshots/
The test code then creates a remote driver:
import os
from selenium import webdriver
options = webdriver.ChromeOptions()
driver = webdriver.Remote(command_executor=os.environ["SELENIUM_REMOTE_URL"], options=options)
In Jenkins the same steps go in a declarative pipeline, with junit in a post { always { } } block. Our Jenkins interview questions cover pipeline syntax in detail.
pipeline {
agent any
stages {
stage('UI tests') {
steps {
sh 'pytest -n 4 --junitxml=results.xml'
}
}
}
post {
always {
junit 'results.xml'
archiveArtifacts artifacts: 'screenshots/**', allowEmptyArchive: true
}
}
}
47. A 2-hour regression suite needs to finish in 20 minutes. What do you change?
Run in parallel on more Grid slots, move setup (logins, data creation) to APIs, delete or push down tests that check logic better covered by API tests, remove fixed sleeps, and split the suite so pull requests run a smoke set and the full suite runs on merge or nightly. Measure the slowest tests first; a few usually take most of the time.
Scenario-based Selenium interview questions
48. A button is visible but clicking it does nothing or throws an exception. How do you debug it?
Check whether the locator matches more than one element and you are clicking a hidden copy. Then check for an overlay (intercepted click), whether the button is disabled until a form is valid, and whether a JavaScript handler is attached late. Wait for element_to_be_clickable, wait for overlays to vanish, and confirm in the browser console that no script error stops the handler.
49. Tests pass on your laptop but fail in CI. What do you check?
Compare the environments: headless mode and window size (responsive layouts hide elements), browser and driver versions, CPU speed (timing problems show up on slower agents), missing fonts or locale, /dev/shm size in Docker, and network access to test services. Reproduce with the same container image locally, and collect screenshots and console logs from the CI run.
50. Content loads by AJAX behind a spinner. How do you wait for it reliably?
Wait for the spinner to become invisible, then wait for the actual content you need, such as a row with expected text. Waiting only for the spinner can pass too early if it appears after a short delay, so the second wait on the target content matters most.
wait = WebDriverWait(driver, 15)
wait.until(EC.invisibility_of_element_located((By.CSS_SELECTOR, ".spinner")))
wait.until(EC.text_to_be_present_in_element((By.ID, "results"), "Order #"))
51. A page uses infinite scroll. How do you find an item that is not loaded yet?
Scroll in a loop: scroll to the last item (or to the bottom with JavaScript), wait for the item count to grow, and stop when the target appears or the count stops changing. Put an upper limit on the loop so a missing item fails the test instead of scrolling forever.
52. You must click Edit in the table row that contains a specific customer name. How?
Locate the row by its text, then the button inside that row. XPath handles this in one expression:
row_edit = driver.find_element(
By.XPATH, "//tr[td[normalize-space()='Asha Patil']]//button[normalize-space()='Edit']")
row_edit.click()
If the table is paginated or sorted by the server, use the search box first so the row is on the current page.
53. Clicking a link opens a new window. How do you work in it and come back?
Store the original handle, click, wait until the number of windows increases, switch to the handle that is not the original, do the checks, close it, and switch back.
original = driver.current_window_handle
driver.find_element(By.LINK_TEXT, "Terms").click()
WebDriverWait(driver, 10).until(EC.number_of_windows_to_be(2))
new = next(h for h in driver.window_handles if h != original)
driver.switch_to.window(new)
assert "Terms" in driver.title
driver.close()
driver.switch_to.window(original)
54. The element is inside an iframe that is inside another iframe. What do you do?
Switch one level at a time from the top: outer frame, then inner frame. Use switch_to.parent_frame() to go up one level and switch_to.default_content() to return to the top. Most "element not found" errors in nested frames come from switching to the inner frame while still on the top page.
55. How do you automate a calendar date picker?
If the input accepts typed dates, clear it and type the date in the expected format, then confirm the value. If it only accepts clicks, open the picker, move month by month until the header shows the target month and year, and click the day using a locator that excludes greyed-out days from neighbouring months. Calculate dates relative to today so the test does not expire.
56. The login flow sends an OTP. How do you automate it?
Do not read real SMS messages. Ask for a test hook: a fixed OTP for test accounts in non-production, an API that returns the latest OTP for a test user, or a TOTP secret for test accounts so the test can generate the code. Keep one manual or monitored check of the real OTP path.
57. The page has a CAPTCHA. How do you automate it?
You do not solve it. CAPTCHAs are built to block automation, and bypassing them on a site you do not own is against their purpose. In your own test environments, disable the CAPTCHA, use the provider's test keys (some providers publish keys that always pass), or allow-list test traffic. Test the CAPTCHA integration separately.
58. One test fails about once in 50 runs on the Grid only. How do you find the cause?
Collect evidence on every failure: screenshot, URL, console log, Grid node name and timing. Look for patterns: one node, one browser version, high parallel load, or a specific time of day. Run the test in a loop under the same parallel load to reproduce it. Typical causes are a missing wait that only matters on a slower node, data shared with another test, or a node with too little memory.
59. Tests pass alone but fail when run in parallel. Why?
They share something: a static driver, the same test user, the same cart or order, a fixed file name for downloads, or a global setting in the application. Give each test its own driver and data, generate unique names, and remove any assumption about test order.
60. You get "session not created: this version of ChromeDriver only supports Chrome version X". How do you fix it?
The driver and browser versions do not match, usually because Chrome auto-updated and an old driver is pinned on the PATH or in the project. Remove the pinned driver so Selenium Manager can resolve the right one, or update it. On agents without internet access, pre-populate the Selenium Manager cache or the driver, and run in offline mode (SE_OFFLINE=true). Behind a proxy, set SE_PROXY so Selenium Manager can reach the download sites.
61. New sessions on the Grid queue up and then time out. What do you check?
Check the Grid UI or status endpoint for free slots and whether the requested capabilities (browser name, version, platform) match any Node. A typo in capabilities or a version no Node offers leaves the request in the New Session Queue until it times out. Then check whether sessions are leaking because tests skip quit(), and add Nodes or autoscaling if the queue is simply longer than capacity.
62. You need to verify the API request a page sends when you click Save. Can Selenium do it?
Yes, with network interception. Enable BiDi and use your binding's network features to listen for requests or responses, or use CDP on Chromium where BiDi coverage in your binding is not ready. For checking business data, an API test against the same endpoint is often simpler and faster than inspecting traffic from the UI test.
63. How do you check that a downloaded PDF has the right content?
Download it to a known folder (see question 32), wait for the file to finish, then open it with a PDF library in your test language and assert on the text, page count or file name. Selenium does not read PDF content itself.
64. The application supports several languages. How do you keep tests from breaking on translated text?
Locate elements by stable attributes, not by visible text. Set the browser locale through options or the application's language setting for each run, and keep expected strings in per-language resource files. Run the full suite in the main language and a smaller set in the others.
65. A dropdown menu opens on hover and closes before you can click the item. What do you do?
Use one Actions chain that moves to the menu, waits briefly if needed, moves to the item and clicks, so the pointer never leaves the menu between steps. Make sure the viewport is wide enough that the desktop menu is shown instead of a mobile hamburger menu.
66. You need to test the mobile layout of the website. How?
For responsive web layouts, set the window size or use Chrome's mobile emulation in options, then run the relevant tests. Emulation does not reproduce real device browsers, so run a smoke set on real devices or a device cloud. For native or hybrid mobile apps, use Appium, which follows the WebDriver protocol.
Preparing for Selenium and test automation interviews
Practise by building a small framework against a public demo site, running it on Grid in Docker, and wiring it into a CI pipeline, then explain each design choice out loud. For more practice, see our advanced Selenium interview questions and the 200+ DevOps interview questions guide, which covers the CI/CD and container topics that test automation roles in DevOps teams are asked about.
If you want guided practice with pipelines that run automated tests, DevOps Training Institute runs classroom batches in Kharadi, Pune and live online classes across India. The Jenkins training and DevOps training courses include CI pipelines that build, test and report on applications.
Frequently asked questions
Which Selenium version should I learn in 2027?
Learn Selenium 4. Version 4.52.0 was the current release in late October 2026, and Selenium 4 is the line that supports Selenium Manager, Grid 4, relative locators and WebDriver BiDi. Interviewers expect Selenium 4 syntax.
Is Java or Python better for Selenium interviews?
Use whichever language the job description names. Java with TestNG or JUnit is common in large enterprise teams, and Python with pytest is common in newer teams. The concepts (waits, locators, Page Object Model, Grid) are the same in every binding.
Do I still need WebDriverManager with Selenium 4?
Usually not. Selenium Manager has been bundled since Selenium 4.6 and downloads the matching driver automatically when none is found. Some older projects still use WebDriverManager, so know what it does.
What is the best way to answer scenario-based Selenium questions?
Describe the symptom, say how you would confirm the cause (screenshot, console log, DOM inspection, rerun), give the fix, and finish with how you would prevent it next time. Interviewers look for an ordered debugging process.
Can Selenium handle CAPTCHA and OTP?
No, and it should not try. Disable CAPTCHA or use the provider's test keys in test environments, and use a fixed test OTP, an OTP lookup API or a TOTP secret for test accounts.
Is Selenium Grid still needed when cloud testing platforms exist?
Many teams use both. Grid 4 in Docker or Kubernetes is cheap for common browsers inside the company network, while cloud grids add many browser, operating system and device combinations without running the infrastructure yourself.
Should I learn Playwright instead of Selenium?
Learn the one your target jobs ask for, and know the differences. Selenium remains widely used, especially in Java teams and companies with an existing Grid, while Playwright is popular for new JavaScript and TypeScript projects.
How many Selenium questions should I prepare?
Be able to answer the freshers' section without notes, write a page object and an explicit wait from memory, and talk through at least ten of the scenarios in detail. Depth on a few real problems counts for more than a long list.
References
- Selenium downloads
- Selenium documentation: Waiting strategies
- Selenium Manager
- Locator strategies and relative locators
- Finding web elements and shadow DOM
- Working with windows and tabs
- Working with iframes and frames
- Selenium Grid components
- Getting started with Selenium Grid
- WebDriver BiDi
- Chrome DevTools Protocol in Selenium
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0