Selenium Senior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. What layers does a maintainable Selenium framework usually have?

    Correct answer: Tests, business flows, page and component objects, driver and config layers

    Each layer changes for its own reasons: UI changes hit pages, business rules hit flows, infrastructure hits driver and config.

  2. 2. Why is classic WebDriver slower per action than tools using CDP or BiDi directly?

    Correct answer: Each command is a separate HTTP round trip to the driver

    On a remote Grid every findElement and click pays network latency. Fewer, coarser commands and BiDi help.

  3. 3. A suite on a remote Grid is twice as slow as locally. What is a likely cause?

    Correct answer: Network latency multiplied by thousands of fine-grained commands

    Move runners close to the Grid, cut chatty helpers like repeated isDisplayed polling, and parallelize.

  4. 4. How should a team decide which browsers to run in CI?

    Correct answer: Use real user analytics, with full runs on main browsers and smoke on others

    Cross-browser cost grows fast. Focus depth where users are and cover the rest with smoke tests.

  5. 5. What's a sound policy for flaky UI tests?

    Correct answer: Track flake rate, quarantine quickly, and fix root causes with owners

    Quarantine keeps the main signal trustworthy; owners and deadlines keep quarantine from becoming a graveyard.

  6. 6. Where does Selenium fit in a healthy test strategy?

    Correct answer: A thin layer of key user journeys on top of unit, API and component tests

    UI tests are the slowest and most brittle. Push logic checks down the pyramid.

  7. 7. How can a team make the UI testable at scale?

    Correct answer: Agree with developers on stable test ids and test hooks in the product

    Testability is a design property. Stable attributes and test-only setup endpoints save more than any locator trick.

  8. 8. What are the risks of self-healing locator tools?

    Correct answer: They can silently click the wrong element and hide real UI changes

    Healing must be visible and reviewed. A test that 'heals' onto a different button gives false confidence.

  9. 9. How do you test a flow with a CAPTCHA?

    Correct answer: Disable or bypass it in test environments through config or keys

    CAPTCHAs are meant to stop bots. Test environments should use test keys or switches; test the CAPTCHA integration separately.

  10. 10. How should UI tests handle 2FA logins?

    Correct answer: Use a test TOTP secret or a test-only bypass in non-production

    Generating TOTP from a stored secret is deterministic. Never weaken security in production for tests.

  11. 11. How do you automate an 'email verification link' flow?

    Correct answer: Read the email through a test mailbox API and open the link

    Services like Mailpit or MailHog expose messages via API; tests fetch the link and continue.

  12. 12. What's the issue with screenshots and logs from tests on staging with real-looking data?

    Correct answer: They may contain personal or sensitive data and must be handled accordingly

    Use synthetic data, mask fields, and restrict access to artifacts.

  13. 13. How do you avoid leaking credentials from Selenium tests in CI?

    Correct answer: Inject them from a secrets store and never print them in logs or reports

    Mask secrets in CI logs and avoid sendKeys logging of password fields in reports.

  14. 14. How can Selenium tests mock backend responses for a UI test?

    Correct answer: Intercept network requests via BiDi, or point the app at a stub server like WireMock

    Stubbing lets you test error states and edge cases the real backend can't produce on demand.

  15. 15. Why is coupling to CDP versions a maintenance cost in Selenium 4?

    Correct answer: CDP APIs are versioned per Chrome release and can break on upgrades

    Prefer BiDi APIs where available; they are a cross-browser standard.

  16. 16. When does migrating from Selenium to Playwright make sense?

    Correct answer: When speed, auto-waiting and tracing matter more than Grid or language legacy

    Weigh team skills, languages, existing infrastructure and cloud Grid contracts. Migrate incrementally.

  17. 17. What's a key difference between Selenium and Playwright waiting?

    Correct answer: Playwright actions auto-wait for actionability; Selenium needs explicit waits

    Selenium frameworks often add a wrapper with smart waits, like Selenide does.

  18. 18. How do you size a self-hosted Grid?

    Correct answer: From parallel sessions needed, browser memory and CPU per session, plus headroom

    Browsers are memory-hungry. Measure per-session usage and scale nodes, often with autoscaling.

  19. 19. What can cause 'zombie' browser processes on CI agents?

    Correct answer: Tests that crash or time out without calling quit

    Ensure teardown runs always, kill leftovers between jobs, or use fresh containers per run.

  20. 20. Why should parallel UI tests use isolated test data, e.g. unique tenants or accounts?

    Correct answer: Shared data makes tests collide and fail depending on timing

    Generate unique users or use per-test tenants; clean up asynchronously.

  21. 21. How do you test features behind feature flags in UI suites?

    Correct answer: Set flags per test through an API or config so both states are covered

    Tests that depend on a global flag state break when someone flips it.

  22. 22. What does acceptInsecureCerts do, and when is it acceptable?

    Correct answer: Lets the browser accept invalid TLS certificates, fine for internal test envs only

    Never rely on it against production; it hides real certificate problems.

  23. 23. How do you add accessibility checks to a Selenium suite?

    Correct answer: Run an engine like axe-core in the page via a library and assert on violations

    Automated checks catch a share of issues; manual and keyboard tests cover the rest.

  24. 24. What metrics help manage a large Selenium suite?

    Correct answer: Flake rate, duration per test, failure causes and time to fix

    Metrics show where to invest: the slowest tests, the flakiest areas, recurring causes.

  25. 25. Why may a page object generator from HTML be a poor idea?

    Correct answer: It creates noisy objects tied to DOM details, not to user intent

    Good page objects model what users do; generated ones mirror markup and break with it.

  26. 26. How should tests deal with time-dependent UI, like 'expires in 3 days'?

    Correct answer: Control time on the server or app side for tests, or assert relative logic

    Backend clock injection or seeded dates make results deterministic.

  27. 27. Why can't Selenium reach elements in a closed shadow root?

    Correct answer: Closed shadow roots aren't exposed to page scripts or WebDriver

    Ask developers for open roots in test builds or test through public behavior.

  28. 28. What limits testing of a cross-origin iframe like a payment widget?

    Correct answer: You can switch into it, but test card flows must use the provider's test mode

    Use sandbox keys and test cards; never hit live payment flows from automation.

  29. 29. How do you speed up a slow UI suite without losing coverage?

    Correct answer: Parallelize, set up state via APIs and move logic checks to lower layers

    Most time is spent on setup and waits. Shortcuts for setup keep UI checks focused.

  30. 30. What problem does sharding a UI suite across CI jobs solve?

    Correct answer: Wall-clock time: tests run on several machines at once

    Balance shards by historical duration, not file count, to avoid one slow shard.

  31. 31. Why record videos of failed UI tests on Grid?

    Correct answer: They show timing issues and transitions that screenshots miss

    Keep videos only for failures to save storage.

  32. 32. What's the downside of a single shared login state for all tests in a suite?

    Correct answer: Tests leak state and can't run safely in parallel or alone

    Authenticate per worker or per test via API to keep isolation.

  33. 33. How should UI tests verify data shown in a grid that comes from an API?

    Correct answer: Compare with data created by the test, not with whatever happens to exist

    Assert on data you control. Shared environments change under you.

  34. 34. What is the danger of very large page objects?

    Correct answer: They become hard to change and hide which parts tests really use

    Split by components. Small objects are easier to review and reuse.

  35. 35. Why should a framework separate 'what' (business steps) from 'how' (UI actions)?

    Correct answer: The same scenario can run through UI, API or both without rewriting tests

    Screenplay or step layers let you swap implementations, e.g. API setup plus UI check.

  36. 36. How do you handle different environments (dev, staging) in a framework?

    Correct answer: Externalize URLs, credentials and toggles in config selected at runtime

    One codebase, many configs; CI passes the environment as a parameter.

  37. 37. What's a good way to review new UI tests?

    Correct answer: Check they test behavior, use stable locators and clean up data

    Review tests like code: readability, independence, failure messages and run time.

  38. 38. Why do implicit waits interact badly with negative checks at scale?

    Correct answer: Each 'not present' check waits the full timeout and slows the suite

    Set implicit waits to zero and use targeted explicit waits for absence.

  39. 39. How can BiDi network events help debug a flaky UI test?

    Correct answer: You see which requests were slow or failed right before the failure

    Attach a network log to failures; many flaky tests are slow or failing APIs.

  40. 40. When is it reasonable to wait for 'network idle' in Selenium?

    Correct answer: Rarely, as a fallback; prefer waiting for the specific UI state

    Polling and analytics keep the network busy forever; idle waits can hang or pass too early.

  41. 41. How do you make UI test failures actionable for developers?

    Correct answer: Attach screenshot, DOM, console and network logs with clear messages

    Evidence in the report avoids 'can't reproduce' loops.

  42. 42. What does testing a single-page app need beyond classic page loads?

    Correct answer: Waiting for client-side rendering and route changes, not load events

    In SPAs the URL can change without a page load. Wait for the target view.

  43. 43. How do you test that a page doesn't make an unexpected API call twice?

    Correct answer: Capture network requests via BiDi and assert on their count

    Duplicate calls cause double orders and load. Network assertions catch them.

  44. 44. Why should UI tests not depend on animations finishing at a fixed time?

    Correct answer: Animation timing varies by machine; wait for the end state instead

    Many teams disable animations in test builds via CSS or a flag.

  45. 45. What is the trade-off of using a cloud Selenium provider?

    Correct answer: Broad browser and device coverage, but cost, latency and vendor lock-in

    Compare cost per parallel session with running your own Grid.

  46. 46. How do you keep a Selenium framework up to date safely?

    Correct answer: Upgrade dependencies regularly in small steps with the suite as a check

    Small upgrades make breakages easy to pin down. Read release notes for W3C or BiDi changes.

  47. 47. Why does a test that uses Thread.sleep 'fix' sometimes hide a product bug?

    Correct answer: It masks real slowness or race conditions users also experience

    If the UI needs 3 seconds to become usable, users feel that too. Report it.

  48. 48. What's a reasonable timeout policy for explicit waits?

    Correct answer: Short defaults with longer, named timeouts only for known slow operations

    Long blanket timeouts make failures slow and hide performance issues.

  49. 49. How do you verify downloads when tests run on a remote Grid?

    Correct answer: Enable managed downloads and fetch the file from the node via the API

    Selenium 4.8+ supports se:downloadsEnabled and downloading files from the session.

  50. 50. What does LocalFileDetector do for file uploads on Grid?

    Correct answer: Sends a local file to the remote node so sendKeys can upload it

    Without it, the path refers to the node's disk, where the file doesn't exist.

  51. 51. Why should tests not share one browser profile on disk?

    Correct answer: Profiles hold state and locks that collide in parallel runs

    Fresh temporary profiles keep cookies, cache and settings isolated.

  52. 52. What should a test framework do with test results over time?

    Correct answer: Keep history to spot trends, slowdowns and newly flaky tests

    Allure history and dashboards turn noise into patterns.

  53. 53. How do you stub a third-party script, like a chat widget, that slows tests?

    Correct answer: Block or stub its requests via BiDi or a test config flag

    Third-party scripts add noise and flakiness; block them unless you test them.

  54. 54. What is a 'test hook' in the product and when is it acceptable?

    Correct answer: A test-only endpoint or flag to set state, guarded out of production

    Hooks like 'create order in state X' make tests fast and stable, if they can't be reached in prod.

  55. 55. Why may a large Selenium suite hit memory limits on agents over a long run?

    Correct answer: Drivers or browsers not quit, and growing logs or screenshots in memory

    Profile the runner; release drivers and stream attachments to disk.

  56. 56. How do you test a site's behavior under a slow network in Selenium 4?

    Correct answer: Throttle the network via CDP or BiDi on supported browsers

    Throttling shows loading states, timeouts and race conditions in the UI.

  57. 57. What does 'test the UI, not the backend, through the browser' mean?

    Correct answer: Check rendering and interaction; verify business rules with API tests

    Each layer tests what it's best at. UI tests confirm wiring and user experience.

  58. 58. Why should exceptions from page objects include the locator and page?

    Correct answer: Failure messages then point straight to the broken element

    A wrapped error like 'CheckoutPage: pay button (data-testid=pay) not clickable' saves time.

  59. 59. How can a team reduce UI test maintenance after redesigns?

    Correct answer: Locate by semantic test ids and roles, and keep logic out of selectors

    Redesigns change CSS and structure; stable ids and good layering absorb most of it.

  60. 60. What does a good failure triage process look like?

    Correct answer: Classify failures (product, test, environment) and route them to owners

    Classification shows whether to fix the app, the test or the infrastructure.

  61. 61. Why should UI tests avoid depending on production-like third-party services?

    Correct answer: Outages and rate limits outside your control fail your suite

    Stub them, or use their sandbox environments with clear SLAs.

  62. 62. How do you decide what goes into a smoke suite?

    Correct answer: The few journeys that must work for the product to be usable

    Smoke runs on every deploy; keep it short and stable.

  63. 63. What's a typical cause of SessionNotCreatedException?

    Correct answer: Driver and browser versions don't match, or Grid has no matching node

    Check versions, capabilities and Grid slots. Selenium Manager helps locally.

  64. 64. Why are mobile web tests via desktop emulation not enough?

    Correct answer: Real devices differ in touch, performance, keyboards and browsers

    Emulation catches layout issues; real devices (e.g. via Appium) catch the rest.

  65. 65. How do you keep UI tests stable across time zones of CI agents?

    Correct answer: Set the browser and app time zone explicitly in tests

    Chromium supports timezone emulation; the app may need a test setting too.

  66. 66. What does a 'quarantine' for flaky tests need to work?

    Correct answer: An owner, a ticket and a deadline for each quarantined test

    Without ownership, quarantine grows until no one trusts the suite.

  67. 67. When is a UI test the wrong tool for a check?

    Correct answer: When the rule can be checked faster and more reliably via API or unit test

    UI tests for every validation rule make suites slow and fragile.

  68. 68. Why should locators be reviewed like code?

    Correct answer: Poor locators cause most maintenance and flakiness later

    A five-minute review prevents months of fixing brittle XPaths.

  69. 69. What's the purpose of a 'canary' run of the UI suite after upgrades?

    Correct answer: Catch breakage from browser or driver updates before all pipelines use them

    Pin versions in main pipelines and test new ones in a canary job first.

  70. 70. How should a framework handle environment instability, like a slow staging?

    Correct answer: Detect and report it separately so test failures aren't blamed on code

    Health checks before runs and clear environment-failure categories keep signal clean.

  71. 71. Why is it useful to tag tests by area and criticality?

    Correct answer: To run focused subsets and route failures to the right team

    Tags like @payments @critical drive selective runs and dashboards.

  72. 72. What should happen when a UI test finds a real bug?

    Correct answer: Report it with evidence, and keep the test failing or link it to the bug

    A test adjusted to a bug hides it. Link known issues instead.

  73. 73. How do you test the same flow in many locales efficiently?

    Correct answer: Data-driven tests with locale parameters and locale-agnostic locators

    Run full checks in key locales and smoke in others; assert translations via resource checks.

  74. 74. Why may a test framework prefer composition of helpers over a deep BaseTest?

    Correct answer: Tests pick only the setup they need and stay easy to read

    A BaseTest that does everything makes every test pay for every setup.

  75. 75. Why should a Selenium framework keep one WebDriver per thread in parallel runs?

    Correct answer: WebDriver is not thread-safe, so shared drivers mix up commands

    Store the driver in a ThreadLocal or inject it per test so parallel tests never touch the same session.