Selenium · Interview preparation · SDET

Selenium Interview Preparation Guide for Automation and SDET Engineers

Progressive interview preparation grounded in official documentation, from fundamentals to production-scale test engineering.

50 questions Easy → Intermediate → Advanced Print-friendly

This guide progresses from daily WebDriver use to protocol, Grid, and test-architecture topics. It is intentionally language-neutral: API spelling varies among Java, Python, JavaScript, C#, Ruby, and Kotlin bindings, while the underlying concepts are shared.

Source and standards note

Only primary official sources are cited:


Easy

E1. What is Selenium WebDriver, and what is it not?

Direct answer: Selenium WebDriver is a browser-automation API and implementation that drives browsers natively, locally or remotely. It is not a test runner, assertion library, or reporting framework.

Explanation: A Selenium language binding sends commands through a browser-specific driver, and the driver controls the browser. A separate framework such as JUnit, NUnit, pytest, or RSpec normally supplies test discovery, assertions, fixtures, and reporting. Keeping these responsibilities distinct is important when diagnosing whether a failure belongs to the test framework, Selenium binding, driver, browser, or application.

Official sources:

Back to top ↑

E2. What are the main parts of basic WebDriver architecture?

Direct answer: The basic path is test code → Selenium language binding → browser driver → browser, with command results returning in the opposite direction.

Explanation: The binding provides the API used by the test. The browser-specific driver—such as ChromeDriver or GeckoDriver—acts as the WebDriver remote end and controls a browser on the same machine as the driver. For remote execution, RemoteWebDriver communicates through Selenium Server or Grid, which routes commands to the machine hosting the driver and browser. WebDriver Classic uses an HTTP request/response command model standardized by W3C.

Official sources:

Back to top ↑

E3. How do you set up a browser driver in modern Selenium?

Direct answer: Install a current Selenium binding and construct the desired browser driver; Selenium Manager is used by the bindings by default when a suitable driver is not otherwise supplied.

Explanation: Browser automation still requires a browser-specific driver. Selenium Manager, shipped with Selenium, discovers, downloads, and caches compatible drivers and can also manage supported browsers. Explicit driver configuration remains possible through PATH or a binding’s Service object, which is useful in controlled or offline environments. Selenium Manager is Selenium tooling, not part of the W3C protocol.

Official sources:

Back to top ↑

E4. What is a WebDriver session?

Direct answer: A session is the logical connection between a WebDriver local end and a specific remote end, identified by a session ID and configured by negotiated capabilities.

Explanation: Creating a driver sends a new-session request. If capability negotiation succeeds, the remote end starts or attaches to a browser and returns the session ID plus actual capabilities. Subsequent commands are scoped to that ID. quit() ends the session; commands sent after deletion normally fail with an invalid-session error.

Official sources:

Back to top ↑

E5. What are capabilities and browser options?

Direct answer: Capabilities are session configuration values exchanged during session creation; Selenium browser-specific Options classes are the normal API for expressing them.

Explanation: Standard capabilities include browserName, browserVersion, platformName, acceptInsecureCerts, pageLoadStrategy, proxy, timeouts, and unhandledPromptBehavior. Browser vendors may add namespaced capabilities such as goog:chromeOptions or moz:firefoxOptions. Selenium 4 guidance is to use browser Options classes rather than legacy DesiredCapabilities, especially for remote sessions.

Official sources:

Back to top ↑

E6. What core element location strategies does Selenium support?

Direct answer: Selenium supports eight traditional strategies: ID, name, class name, CSS selector, XPath, link text, partial link text, and tag name.

Explanation: ID matches an element’s id; name matches name; class name accepts one class rather than a compound class string; CSS selector and XPath evaluate selector expressions; link text and partial link text apply to links by rendered text; tag name matches the element tag. Prefer a unique, stable ID when available, otherwise a compact CSS selector; use XPath when its capabilities materially help.

Official sources:

Back to top ↑

E7. How do findElement and findElements differ?

Direct answer: A singular find returns the first matching element or raises a no-such-element error; a plural find returns all matches and returns an empty collection when none match.

Explanation: Both searches run in a search context: the whole current document when called on the driver, or descendants when called on an element or shadow root. Singular lookup is appropriate for a required unique element. Plural lookup is appropriate for collections or optional presence checks, but assertions should still state the expected count or condition.

Official sources:

Back to top ↑

E8. What are the main WebElement interactions?

Direct answer: The common operations are click, send keys, clear, and querying element state or information; select-list support is provided by Selenium helpers.

Explanation: WebDriver checks interactability before user-like operations. A click targets the element’s in-view center and can fail if another element obscures it. Send keys requires a keyboard-interactable target, and clear requires an editable/resettable target. Read-only queries include text, attributes/properties, tag name, rectangle, enabled, selected, and displayed state, although displayedness has Selenium-specific implementation details.

Official sources:

Back to top ↑

E9. Why are waits needed in UI automation?

Direct answer: Waits synchronize a test with application state that may become ready after navigation itself has completed.

Explanation: Navigation waits according to the page-load strategy and document readiness, but client-side JavaScript can continue changing the UI afterward. An implicit wait globally retries element location. An explicit wait polls for a specific condition, such as visibility, clickability, text, URL, or disappearance. Fixed sleeps always consume their full duration and do not express the actual readiness condition.

Official sources:

Back to top ↑

E10. How do you work with multiple windows or tabs?

Direct answer: Save the original window handle, wait for the set of handles to change, switch to the target handle, and later close it and switch back.

Explanation: WebDriver treats windows and tabs uniformly as top-level browsing contexts, each with a unique handle during the session. A newly opened tab does not make WebDriver’s current context change automatically unless it was created through the new-window command. After closing a non-final window, explicitly switch to a remaining valid handle or later commands can fail with NoSuchWindow.

Official sources:

Back to top ↑

E11. How do you interact with frames and iframes?

Direct answer: Switch into the frame by element, name/ID, or index; interact within it; then switch to the parent frame or default content.

Explanation: Element lookup is scoped to the current browsing context. An element inside an iframe is therefore invisible to a search from the top-level document until the driver switches context. Element-based frame selection is generally more robust than an index because document order can change. defaultContent returns to the top-level context.

Official sources:

Back to top ↑

E12. How do you handle JavaScript alerts, confirms, and prompts?

Direct answer: Wait for the alert, switch to it, then read its text, accept or dismiss it, and for a prompt optionally send text before accepting.

Explanation: These browser-native dialogs are not DOM elements and cannot be found with element locators. The WebDriver alert commands operate on the current user prompt. Session capability unhandledPromptBehavior controls what the remote end should do when a command encounters an unexpected prompt.

Official sources:

Back to top ↑

E13. How does WebDriver manage cookies?

Direct answer: WebDriver can add, retrieve, and delete cookies for the current browsing context’s active document domain.

Explanation: Navigate to an appropriate URL before adding a cookie; adding one for an unrelated domain is invalid. Cookie fields can include name, value, path, domain, secure, HTTP-only, expiry, and SameSite. Cookies are useful for session setup, but tests should avoid leaking them across cases by using fresh sessions or explicit cleanup.

Official sources:

Back to top ↑

E14. How should file upload and download be handled?

Direct answer: Upload by sending an absolute path to an input[type=file]; for validating downloads, Selenium recommends obtaining the link and cookies with WebDriver and using an HTTP client.

Explanation: Selenium cannot control the operating system’s file-picker dialog, so clicking it is the wrong abstraction. Sending the path directly to the file input is supported. A browser can start a download under Selenium, but WebDriver Classic does not expose a standard download-progress API, making completion and file validation unreliable; an HTTP library is usually clearer.

Official sources:

Back to top ↑

E15. What is the difference between close() and quit()?

Direct answer: close() closes the current top-level browsing context; quit() ends the entire WebDriver session and closes its associated browsing contexts.

Explanation: Use close() when intentionally managing one tab or window and then switch to another valid handle. Use quit() in teardown, preferably in a finally block or fixture finalizer, so browser and driver processes are released even after a failed assertion. Closing the last window may implicitly end the session depending on remote-end behavior, but teardown should still express session cleanup explicitly.

Official sources:

Back to top ↑

E16. What is the simplest rule for test isolation?

Direct answer: Each test should own independent data and a fresh WebDriver instance, and it should be runnable alone in any order.

Explanation: Shared users, mutable records, cookies, or browser sessions create ordering dependencies and parallel-execution races. Selenium explicitly recommends a new driver per test because it isolates browser state and simplifies parallelization. Fixtures should create required state, yield the driver, and always clean up both application data and the session.

Official sources:

Back to top ↑

Intermediate

I1. How should explicit, implicit, and fluent waits be chosen?

Direct answer: Prefer explicit waits for specific state transitions; use implicit wait sparingly and never mix it with explicit waits; use a fluent/custom wait when polling interval, ignored exceptions, or conditions need control.

Explanation: Implicit wait affects every element lookup for the session, which hides where synchronization is required. Explicit waits document the expected state at the relevant action. Mixing the two can produce unpredictable compounded timeout durations. A fluent wait is still an explicit polling loop, but with configurable timeout, polling cadence, and exception handling.

Official sources:

Back to top ↑

I2. What makes a locator robust?

Direct answer: A robust locator identifies a stable, meaningful attribute with the smallest readable selector that uniquely expresses intent.

Explanation: Prefer application-provided unique IDs or dedicated stable attributes. Avoid generated IDs, positional XPath, long DOM ancestry, style classes, and visible text that changes with localization unless those are the behavior under test. Scope within a stable component when useful. A locator should fail because the contract changed, not because unrelated markup moved.

Official sources:

Back to top ↑

I3. What causes StaleElementReferenceException, and how should it be fixed?

Direct answer: It occurs when a stored element reference no longer points to an attached element in the current document or context; relocate the element after the DOM/context change.

Explanation: Drivers represent elements by remote reference IDs, not by permanently re-running their locators. Navigation, refresh, frame changes, and client-side replacement can invalidate a reference. Wait for the intended transition, then locate again as close as possible to the interaction. Blindly retrying every stale exception can conceal a real application loop or wrong context.

Official sources:

Back to top ↑

I4. How do ElementClickIntercepted and ElementNotInteractable differ?

Direct answer: Intercepted means another element would receive the center-point click; not interactable means the target does not meet the interaction requirements, such as visibility, viewport, or keyboard editability.

Explanation: For interception, inspect overlays, sticky headers, animations, and layout shifts, then wait for the blocker to disappear or the layout to stabilize. For non-interactability, verify the correct element and context, its displayed/enabled state, and the operation’s semantics. JavaScript-clicking immediately bypasses useful user-like checks and often hides the defect.

Official sources:

Back to top ↑

I5. When should the Actions API be used?

Direct answer: Use Actions for composite or low-level input such as hover, drag, click-and-hold, chorded keys, context click, precise pointer movement, and wheel scrolling.

Explanation: Normal element click and send-keys commands are simpler for ordinary controls. Actions models virtual input sources—key, pointer, and wheel—and builds sequences that execute on perform(). Release depressed keys/buttons after exceptional paths to prevent state leaking into later interactions. Actions is standardized at the protocol level, while convenience method names vary by binding.

Official sources:

Back to top ↑

I6. When is JavaScript execution appropriate?

Direct answer: Use script execution to inspect or perform browser-side behavior that WebDriver’s user-facing commands do not expose, not as the default replacement for normal interactions.

Explanation: WebDriver Classic defines synchronous and asynchronous script commands. Arguments and return values are serialized between local and remote ends, including supported element references. Appropriate uses include reading application state that has no user-visible representation or invoking a test hook. Scripted clicks and direct DOM mutation bypass interactability, input events, accessibility behavior, and real-user constraints.

Official sources:

Back to top ↑

I7. What do page-load strategy and WebDriver timeouts control?

Direct answer: Page-load strategy controls when navigation returns; script, page-load, and implicit timeouts control script execution, navigation, and element lookup respectively.

Explanation: normal generally waits for document readiness complete, eager returns at interactive, and none does not block for document readiness. These are session-wide choices and do not guarantee a JavaScript application is usable. Lowering navigation blocking therefore requires explicit application-readiness waits, not an assumption that the UI is ready.

Official sources:

Back to top ↑

I8. What are relative locators, and what are their trade-offs?

Direct answer: Selenium relative locators find an element above, below, left of, right of, or near another element based on rendered geometry.

Explanation: They are Selenium convenience APIs, not additional W3C WebDriver locator strategies. They help when semantic attributes are weak but a stable neighboring label or control exists. Because geometry changes with responsive layouts, zoom, fonts, and overlapping rectangles, a stable ID or CSS selector is usually preferable. Chaining spatial relationships can narrow candidates but can also increase layout sensitivity.

Official sources:

Back to top ↑

I9. How are elements inside Shadow DOM located?

Direct answer: Locate the shadow host, obtain its shadow root, and locate descendants within that shadow-root search context.

Explanation: Shadow DOM encapsulates its subtree, so a document-level CSS selector does not cross the boundary. Selenium 4 exposes shadow-root methods in supported browsers. Repeat the process for nested shadow roots. This differs from a frame: a shadow root changes the search context, whereas a frame changes the browsing context.

Official sources:

Back to top ↑

I10. What is a Page Object Model, and where should assertions live?

Direct answer: A Page Object models the services a page or component offers and centralizes its locators and interaction details; test assertions normally remain in tests.

Explanation: Page Objects reduce duplication and isolate UI structure changes. Methods should express business-facing actions and may return another page/component object to model navigation. Selenium’s guidance allows a page object to verify that the expected page loaded during construction, but it should not contain the test’s behavioral assertions. Avoid exposing the raw driver unless a real extension point requires it.

Official sources:

Back to top ↑

I11. How should context changes be synchronized?

Direct answer: Wait for observable context state—new handle count, frame availability, alert presence, URL/title, or target element—then switch and verify the target context.

Explanation: A click that starts navigation or opens a tab is not proof that the new context is ready. Capture the previous handles or URL before the trigger, wait for a meaningful change, switch explicitly, and assert a stable marker. The same principle applies when returning from frames or alerts: context is part of test state and should be deliberate.

Official sources:

Back to top ↑

I12. What evidence should a failing UI test capture?

Direct answer: Capture the exception, current URL and title, screenshot, relevant DOM or element state, browser/driver logs when available, capabilities, and timing/context information.

Explanation: Evidence should be collected before teardown changes the state. A screenshot alone may miss hidden overlays, wrong frames, stale references, or console errors. Selenium provides full-page-viewport and element screenshots plus configurable command logging; browser log availability varies. Reproduce across browsers to distinguish Selenium usage from an underlying driver/browser defect.

Official sources:

Back to top ↑

I13. What problem does Selenium Grid solve?

Direct answer: Grid runs WebDriver sessions on remote machines and distributes them across browser, version, platform, and capacity combinations.

Explanation: Tests create RemoteWebDriver sessions against the Grid endpoint and request capabilities. Grid matches each request to an available Node slot. This enables parallel execution and cross-browser coverage without requiring every test-runner host to contain every browser. Grid can run as Standalone, Hub/Node, or fully distributed components.

Official sources:

Back to top ↑

I14. How does Grid choose where to run a requested session?

Direct answer: The new-session request enters the queue, and the Distributor matches its capabilities to an available Node slot.

Explanation: Browser Options become the W3C capability request. A Node advertises stereotypes/capabilities and available slots. If no compatible slot is currently available, the request remains queued until timeout or capacity becomes available. Request only constraints that matter: over-constraining exact browser versions or platforms can prevent an otherwise valid match.

Official sources:

Back to top ↑

I15. Which practices does Selenium explicitly discourage?

Direct answer: Selenium discourages automating CAPTCHAs and 2FA directly, using WebDriver as the primary download validator, and treating HTTP status-code checks as the main UI-test concern.

Explanation: CAPTCHA is designed to defeat automation; use a test-environment bypass. For 2FA, use controlled test tokens, users, or environment configuration without weakening production. For downloads, transfer the discovered URL and cookies to an HTTP client. For response codes, assert what the user sees or use a deliberate network/proxy layer when protocol validation is truly required.

Official sources:

Back to top ↑

I16. What is a disciplined first-pass troubleshooting sequence?

Direct answer: Classify the failure, verify synchronization and context, inspect artifacts and capabilities, confirm driver/browser compatibility, reproduce minimally, and compare browsers.

Explanation: Most flaky failures are synchronization or state problems, while session-creation failures often involve versions, binaries, permissions, or invalid capabilities. Enable Selenium/driver logging and retain the smallest reproducible case. Testing the same command in another browser helps locate the fault boundary. A temporary long sleep can diagnose a timing suspicion, but replace it with a condition wait rather than keeping it.

Official sources:

Back to top ↑

Advanced

A1. How does the W3C WebDriver Classic protocol divide responsibilities?

Direct answer: The local end accepts client-library calls and sends protocol commands; the remote end receives them, controls the user agent, and returns standardized success or error responses.

Explanation: Commands are HTTP endpoints scoped mostly by session ID, such as finding an element, performing actions, or managing cookies. Selenium bindings are local-end implementations; browser drivers are commonly remote ends. Selenium Server/Grid can act as an intermediary and router without changing the command semantics. This wire-level separation explains why binding, Grid, driver, and browser versions can fail independently.

Official sources:

Back to top ↑

A2. How does W3C capability negotiation use alwaysMatch and firstMatch?

Direct answer: The remote end merges alwaysMatch with each firstMatch candidate in order and selects the first merged set it can satisfy.

Explanation: alwaysMatch contains requirements common to every acceptable configuration; firstMatch expresses alternatives. Duplicate keys across a common set and an alternative conflict and make that combination invalid. Standard capability names are unprefixed; extension capabilities must contain a vendor prefix separated by a colon. Selenium Options normally builds the correct payload, but understanding it is essential for Grid and cloud diagnostics.

Official sources:

Back to top ↑

A3. What is the lifecycle of a remote element reference?

Direct answer: A remote end maps an element to a protocol reference valid only within its session and browsing context while the node remains connected to the active document.

Explanation: Element objects in a binding serialize using the WebDriver element identifier. Before commands, the remote end resolves the reference and checks context and staleness. Document replacement, node removal, or the wrong frame can invalidate it. Architect tests around locators and page services rather than globally cached WebElement instances, especially in reactive applications.

Official sources:

Back to top ↑

A4. How are multi-device Actions sequences executed?

Direct answer: The protocol executes input-source action lists in synchronized ticks, dispatching each source’s action for a tick together and using pauses to align sequences.

Explanation: Each source has an ID and type—key, pointer, wheel, or none—and its state persists for the session until changed or released. Tick duration is influenced by the longest action in that tick. This enables combinations such as holding a modifier while moving and clicking a pointer. Malformed unequal concepts should be represented with pause actions, and cleanup should release active inputs.

Official sources:

Back to top ↑

A5. What are Selenium Grid’s six core components and session flow?

Direct answer: Router, New Session Queue, Distributor, Node, Session Map, and Event Bus cooperate to queue, place, run, and route sessions.

Explanation: The Router is the external entry point. It sends new sessions to the Queue; the Distributor polls requests, matches a Node slot, creates the session, and records session-to-Node location in the Session Map. Existing-session commands are routed to that Node. The Event Bus carries internal asynchronous messages such as registration. Standalone and Hub/Node package these same responsibilities rather than changing them.

Official sources:

Back to top ↑

A6. How should parallel Grid capacity be designed?

Direct answer: Size concurrency to available Node slots and application capacity, isolate every test, and let the runner schedule independent tests rather than sharing sessions.

Explanation: More test threads than slots mostly create queueing, not throughput. Browser sessions consume CPU, memory, ports, and sometimes display resources; overloaded Nodes produce misleading timeouts. Use one driver per test, unique data, deterministic teardown, and capability-based pools. Monitor queue time separately from test time so infrastructure contention is not misclassified as application slowness.

Official sources:

Back to top ↑

A7. How do WebDriver Classic and WebDriver BiDi differ?

Direct answer: Classic is primarily synchronous HTTP request/response automation; BiDi adds a standardized bidirectional channel for commands plus asynchronous browser events.

Explanation: Classic remains the broadly implemented foundation for navigation, elements, contexts, input, cookies, and scripts. BiDi uses WebSocket-based communication to subscribe to events and support domains such as logging, network, browsing context, and script. BiDi is a separate evolving W3C specification, and Selenium is adding high-level APIs while preserving Classic compatibility where possible.

Official sources:

Back to top ↑

A8. Where does CDP fit, and why is it not equivalent to BiDi?

Direct answer: CDP is Chromium’s version-sensitive developer-tools protocol; WebDriver BiDi is the standards-based, cross-browser target, and Selenium’s CDP access is temporary compatibility functionality.

Explanation: CDP can expose network, console, emulation, and debugging features before equivalent BiDi support exists, but its API can change with browser versions. Selenium supports generated CDP bindings only for a limited set of recent Chrome versions. Code tightly coupled to CDP is therefore browser- and version-specific. Prefer Classic for standard commands and BiDi for supported event-driven use cases.

Official sources:

Back to top ↑

A9. How should event-driven network and logging tests be designed with BiDi?

Direct answer: Enable BiDi, subscribe before the triggering action, filter narrowly, retain unsubscribe/cleanup handles, and assert only events relevant to the test contract.

Explanation: Events can race with subscription if listeners are installed after navigation or interaction. Broad listeners create noise, memory pressure, and cross-test leakage when sessions are reused. Selenium’s high-level BiDi APIs are preferred over binding directly to low-level protocol details when available. Feature availability varies by Selenium binding and browser, so capability detection and version-controlled CI matrices are necessary.

Official sources:

Back to top ↑

A10. What security boundary should be applied to Selenium Grid?

Direct answer: Treat Grid as privileged infrastructure, keep it on a trusted network, restrict ingress to the Router, and never expose it openly to the public Internet.

Explanation: Grid can create browser processes and execute automation across Nodes, so an unauthenticated public endpoint is a serious risk. Selenium’s architecture documentation explicitly cautions against wider Web exposure. Apply network controls, authentication at a trusted proxy where needed, least-privilege runtime users, patched images, secret isolation, and controlled artifact access.

Official sources:

Back to top ↑

A11. What does robust end-to-end test design look like?

Direct answer: Test user-visible outcomes through stable page/component services, explicit state-based synchronization, isolated data, and the smallest valuable cross-browser matrix.

Explanation: Keep setup through APIs when UI behavior is not under test, then use WebDriver for the user journey being validated. Assert durable business outcomes rather than incidental markup. Centralize locators and interaction policy without hiding failures behind generic retries. Keep tests independent, collect diagnostic artifacts, and reserve exhaustive permutations for lower test layers where they run faster and fail more precisely.

Official sources:

Back to top ↑

A12. Why are generic retries dangerous, and when is a retry defensible?

Direct answer: Generic retries hide deterministic defects and inflate runtime; a bounded retry is defensible only around a known transient boundary with fresh state and retained evidence.

Explanation: Retrying clicks, stale references, or whole tests without diagnosis can turn an application race into a pass and corrupt reliability metrics. First replace timing guesses with explicit conditions and fix shared state. If infrastructure occasionally fails before the test starts, retry at that boundary, create a new session, preserve the first failure, and report retry rates. Selenium’s troubleshooting guidance emphasizes root-cause synchronization and driver comparison.

Official sources:

Back to top ↑

A13. How do you design a custom wait for a frequently re-rendered UI?

Direct answer: Poll a locator-based predicate that re-finds elements, handles only expected transient exceptions, and returns a meaningful stable result before a bounded timeout.

Explanation: Capturing one element before polling invites staleness when the framework replaces nodes. Instead, locate inside each poll and test the actual condition—such as text, enabled state, item count, or absence of an overlay. Ignore only exceptions that represent the expected transition. Include the condition and observed state in timeout diagnostics; do not swallow assertion or session errors.

Official sources:

Back to top ↑

A14. Why should JavaScript-based interaction remain an escape hatch?

Direct answer: JavaScript can bypass the WebDriver interactability algorithm and therefore may pass even when a real keyboard or pointer user cannot perform the action.

Explanation: WebDriver click scrolls into view, targets the in-view center, and checks whether another element would receive the click. Directly calling DOM click() does not prove those conditions and may dispatch a different event sequence. Use JavaScript for explicit browser-side inspection or test hooks, document why standard interaction is insufficient, and keep a user-like assertion afterward.

Official sources:

Back to top ↑

A15. What extra file-transfer issues appear in remote/Grid execution?

Direct answer: The test runner’s filesystem and the remote browser Node’s filesystem are different, so uploads need binding/Grid file-transfer support and downloads need an explicit artifact strategy.

Explanation: A local path sent to a remote session is meaningless unless Selenium’s remote file detector or equivalent binding mechanism transfers it to the Node before setting the file input. Download destinations exist on the Node, not necessarily the runner, and Classic WebDriver does not standardize progress. Prefer HTTP validation when possible; otherwise configure isolated download directories and an explicit secure artifact retrieval mechanism.

Official sources:

Back to top ↑

A16. How should an engineer distinguish standards from Selenium-specific guidance?

Direct answer: Treat W3C specifications as protocol contracts; treat Selenium APIs, Manager, Grid, relative locators, Page Objects, and practice guidance as project-level implementations or recommendations.

Explanation: Classic commands such as sessions, capabilities, element lookup, actions, contexts, cookies, and script execution are specified by W3C, though implementations can still have defects. BiDi is a separate evolving W3C protocol. Selenium supplies language ergonomics, driver/browser management, distributed routing, and design guidance. CDP is vendor-specific. Naming the layer prevents claims such as “Page Object is a WebDriver standard” or “CDP is cross-browser.”

Official sources:

Back to top ↑

A17. How do you investigate a flaky Selenium test?

Direct answer: Reproduce and classify the intermittent failure, collect browser and test evidence, isolate timing, data, environment, and concurrency variables, fix the root cause, and verify the test repeatedly. Do not treat reruns or longer sleeps as the solution.

A practical daily workflow:

  1. Make the failure observable. Repeat the test with the same browser, driver, data, and Grid environment. Capture the exception, screenshot, page source when useful, browser console, session details, timestamps, and server/Grid logs.
  2. Classify the symptom. A stale element usually suggests a replaced DOM node; an intercepted click suggests an overlay or animation; a missing element suggests synchronization, frame, window, or locator scope; session failures suggest driver, browser, or infrastructure issues.
  3. Isolate variables. Run the test alone and sequentially, then restore parallelism. Check whether tests share a driver, account, record, download directory, or mutable environment. Confirm browser and driver compatibility.
  4. Fix the cause. Replace sleeps with an explicit wait for the business-relevant condition, locate elements again after DOM updates, use stable locators, create a new WebDriver per test, and assign unique data to parallel runs.
  5. Prove stability. Repeat locally and on Grid under normal load. Preserve useful diagnostics and track recurrence; do not hide an unresolved failure behind automatic reruns.

Example: A “Save” click intermittently raised StaleElementReferenceException because a React update replaced the button after validation. The fix was to wait for validation to finish and locate the button inside the wait instead of caching the old WebElement.

Official sources:

Back to top ↑

A18. What challenges have you faced during test automation, and how did you handle them?

Direct answer: Describe a genuine problem with its impact, the evidence you gathered, the engineering change you made, and the result. Avoid a generic list with no ownership or outcome.

Common daily-life challenges:

Sample interview answer: “Our order-history test passed locally but failed on Grid because parallel tests reused the same customer and overwrote the latest order. Logs showed different sessions reading the same record. I generated unique customer data per test, stopped sharing WebDriver instances, and moved setup to an API. This removed the data race and shortened execution. I then kept screenshots and Grid session IDs in reports so future failures were easier to triage.” Use your own facts and metrics when answering.

Official sources:

Back to top ↑

Final review checklist

Original-content and license note

This interview guide is newly authored original content and may be shared or adapted. Selenium names, logos, trademarks, source code, specifications, and linked documentation remain subject to the terms, licenses, and trademark policies of their respective owners. Citations are links to those owners’ materials and do not relicense them.