These Selenium Interview questions will help you for your interview so prepare all and share your answers in comments. Also, if you have any new questions, please let us know in comments. Questions and Answers will be selected from your comments and added to this note.
=== 2025 Update: Latest Selenium Interview Questions and Answers (Freshers + Experienced) ===
Note: The below sections add the latest, practical Q&A without removing the existing content. Use them to refresh your preparation for 2025 roles.
— Freshers: Core Concepts & Getting Started —
1) What changed in Selenium since 4.x? What is BiDi?
Answer: Selenium 4 adopted the W3C WebDriver standard completely, introduced the Selenium Grid 4 event bus & distributed mode, relative locators, native support for Edge/Chrome DevTools via BiDi (bidirectional protocols) for network interception, console logs, coverage, and emulation. Prefer WebDriverManager or official driver-manager in Selenium 4.6+ to auto-manage drivers.
2) How do you manage drivers in 2025?
Answer: Prefer Selenium Manager (built-in) introduced in Selenium 4.6+ or WebDriverManager (Bonigarcia) to auto-download the right browser drivers. Avoid hardcoding driver paths; use: WebDriver driver = new ChromeDriver(); Selenium Manager resolves binaries automatically.
3) Best locator strategy today?
Answer: Prefer data-testid or stable attributes with CSS selectors. Use accessible roles (aria-label, role) where possible. Keep XPath short and resilient, avoid brittle absolute paths. For React/Angular apps, target stable ids or test attributes.
4) How do you handle waits reliably?
Answer: Use explicit waits with ExpectedConditions (visibilityOfElementLocated, elementToBeClickable) or SeleniumSupport Wait + predicates. Avoid Thread.sleep(). Combine waits with retry logic to reduce flakiness.
— Experienced: Advanced Techniques & Real-World Scenarios —
5) How to intercept network requests/validate APIs in UI tests?
Answer: Use Chrome/Edge DevTools Protocol via Selenium 4 BiDi (or Selenide + CDP). You can block/modify requests, capture HAR-like data, assert response codes, and mock endpoints to stabilize tests. Keep contract checks in API tests (RestAssured) and use UI for end-to-end validations.
6) What’s your strategy for reducing flaky tests?
Answer:
- Stabilize locators and page-load synchronizations (explicit waits, conditions on network idle/state).
- Isolate test data; create it via APIs/DB and clean up after.
- Use idempotent setup/teardown, avoid inter-test coupling.
- Add retries only as last resort with failure screenshots, console logs, and network traces.
7) How do you design a scalable Selenium framework in 2025?
Answer: Hybrid POM + Page Factory or Screenplay pattern, with:
- Modular layers (DriverFactory, Page Objects/Tasks, Services, Utilities)
- Config via environment variables or .properties/YAML
- Data-driven via TestNG/JUnit + DataProvider/CSV/Excel
- Reporting (Allure/Extent) with screenshots, console/network logs
- Parallel runs via TestNG + Grid 4 or cloud (BrowserStack/Sauce/Playwright grid), CI via GitHub Actions/Jenkins
- Test tagging (smoke, regression) and shard by tag
8) What about cross-browser and WebDriver alternatives?
Answer: Selenium remains dominant for cross-browser E2E with real browsers. Some teams adopt Playwright for speed and built-in tracing; Cypress for component/e2e in JS ecosystems. For Java shops with existing suites, keep Selenium, adopt BiDi features, and improve infra (Dockerized Grid, parallelism) rather than migrating wholesale.
9) How to handle modern auth (SSO, OAuth, MFA)?
Answer: Avoid UI-based login for every test. Use API tokens, pre-seeded cookies/sessions, or service-level login flows. For MFA, stub in lower envs, or use test accounts with MFA bypass. Keep pure auth flows as a small dedicated e2e set.
10) How do you tackle dynamic components and virtualized lists?
Answer: Scroll into view and wait for rendering, use attribute-based anchors (data-row-id), and verify via DOM snapshot size changes. For virtual lists, assert on visible window + server/API response, not entire off-DOM items.
— New Trends & Common Challenges (2025) —
11) What’s the right place for visual testing?
Answer: Use visual tools (Applitools, Percy) for intentional UI regressions. Keep functional assertions in Selenium, visual diffs for layout changes, and tolerate minor anti-aliasing via smart baselines.
12) How to run fast at scale?
Answer: Shift-left: push logic into API/component tests, keep Selenium for E2E happy-paths. Run Selenium in parallel (10–50+ nodes) with ephemeral Docker Grid, cache drivers, and warm browsers. Use test impact analysis to run only changed-coverage tests in PRs.
13) Handling file uploads/downloads reliably?
Answer: Use input[type=file].sendKeys for uploads where possible. For downloads, set browser preferences to a temp directory and verify file existence and checksum. Alternatively, validate via API if the file is served from backend.
14) StaleElementReferenceException—modern fixes?
Answer: Re-locate on interaction, use ExpectedConditions.refreshed, and rely on wait until DOM stabilizes. Prefer event-driven waits (network idle) when using BiDi/DevTools.
15) How do you assert network failures or offline behavior?
Answer: Use DevTools to emulate offline/slow 3G, block specific hosts, and assert UI fallback states (toasts, cached content). Keep these in a small non-parallel suite due to browser-level toggles.
— Code Snippets (Java, Selenium 4) —
A) Driver management with Selenium Manager:
WebDriver driver = new ChromeDriver(); // Selenium 4.6+ resolves driver
B) Explicit wait helper:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement btn = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(“button[data-testid=’pay’]”)));
btn.click();
C) Relative locators:
WebElement price = driver.findElement(with(By.tagName(“span”)).below(By.id(“title”)));
D) Capture console logs (CDP in Selenium 4):
DevTools devTools = ((HasDevTools) driver).getDevTools();
devTools.createSession();
devTools.send(Log.enable());
devTools.addListener(Log.entryAdded(), e -> System.out.println(e.getText()));
E) Network interception (mocking):
devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
devTools.addListener(Network.requestWillBeSent(), e -> System.out.println(e.getRequest().getUrl()));
— Interview Scenarios & Answers —
16) Prioritizing tests for automation
Answer: High business impact, stable flows, high frequency, data determinism, and ROI. Defer unstable, highly visual, or third-party dependent flows to API/component layers.
17) Handling feature flags and A/B tests
Answer: Force flags via API/config, or navigate to a deterministic variant. In CI, run with flags pinned to avoid variant-induced flakiness.
18) Test data strategy
Answer: Create via public API/DB fixtures, seed via factories, and clean with soft deletes or TTL. Use unique ids to avoid collisions in parallel runs.
19) CI/CD integration best practices
Answer: Parallel shards, environment bootstrap (migrations, seed), artifact retention (screenshots, traces, logs), flaky test quarantine with auto-retry + ticketing, and nightly full regressions.
20) Accessibility checks
Answer: Integrate axe-core checks in UI suites for basic violations. Keep full accessibility audits outside Selenium where possible.
— Quickfire FAQs (2025) —
- Can Selenium automate Captcha? No; use test bypasses or mocks.
- Headless vs headed? Headless is faster but less faithful for some rendering; validate critical flows in headed.
- Playwright vs Selenium? Playwright is fast with rich tracing; Selenium excels for Java ecosystems and broad grid support. Many orgs use both.
- Mobile web? Use real devices or cloud device farms; for native apps prefer Appium 2.
References for Further Study:
- Simplilearn: Top 90+ Selenium Interview Questions (2025/2026)
- Hirist: 70+ Selenium Interview Q&A (2025)
- Turing: 100 Selenium Interview Questions (2025)
- InterviewBit: Selenium Q&A for 5+ years experience
End of 2025 update.
hi,your blog is very useful. all the questions are so challenging. thank you for posting all important questions.
http://www.trainingpune.in/selenium-training-in-pune.html