Selenium Interview Questions for Freshers and Experienced

Twenty-five Selenium interview questions with clear answers — locators, waits, exceptions and WebDriver basics for freshers, then framework design, Grid, flaky tests and Selenium 4 changes for experienced testers.

Quick Answer: Fresher Selenium interviews focus on locators, waits, WebDriver commands, exceptions and handling alerts, frames and windows. Experienced rounds move to framework design, Page Object Model, parallel execution, Grid, flaky tests, CI integration and what changed in Selenium 4. Below are twenty-five questions across both levels, with answers you can explain rather than recite.

Selenium remains the most commonly listed automation skill in Indian QA job postings, especially in services companies with long-running client test suites. That also means interviewers have heard every memorised answer many times. What separates candidates is the follow-up — "why would you do that", "what happens if", "how would you fix it" — so the answers below focus on reasoning as much as on facts.

Selenium Interview Questions for Freshers

1. What is Selenium and what are its components?

Selenium is an open-source suite for automating web browsers. Its current components are WebDriver, which drives the browser through its native automation support; Selenium Grid, which runs tests across multiple machines and browsers in parallel; and Selenium IDE, a record-and-playback browser extension useful for quick prototypes. Selenium RC is the legacy component and is no longer used.

2. What are the limitations of Selenium?

It automates web applications only — not desktop or native mobile apps without additional tools. It cannot handle CAPTCHA or read OTPs by design. It has no built-in reporting or test management, so it is paired with TestNG, JUnit, pytest and reporting libraries. Image-based validation needs third-party tools. Knowing these limits is itself what the question tests.

3. What locators does Selenium support?

ID, name, className, tagName, linkText, partialLinkText, CSS selector and XPath. Selenium 4 added relative locators such as above, below, toLeftOf, toRightOf and near. The preferred order in practice is ID when it is stable and unique, then CSS selectors, then XPath when you need to traverse or match on text.

4. What is the difference between absolute and relative XPath?

Absolute XPath starts from the root with a single slash and follows the full path down the DOM, so any layout change breaks it. Relative XPath starts with a double slash and finds the element anywhere by its attributes or text, which makes it far more resilient. Absolute XPath in a framework is generally treated as a red flag in code review.

5. What is the difference between findElement and findElements?

findElement returns the first matching element and throws NoSuchElementException if none is found. findElements returns a list of all matches and returns an empty list rather than throwing when nothing matches — which makes it the safer way to check whether an element exists.

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

close() closes the current browser window only. quit() closes every window and ends the WebDriver session. Using close() in teardown leaves driver processes running in the background, which slowly consumes memory on a test machine.

7. What is the difference between get() and navigate().to()?

Both load a URL and wait for the page load to complete. The navigate interface additionally offers back, forward and refresh, and keeps browser history, which is why it is used when a test needs to move between pages rather than simply open one.

8. What types of waits exist in Selenium?

An implicit wait sets a global polling time for every element lookup. An explicit wait, using WebDriverWait with ExpectedConditions, waits for a specific condition on a specific element — visibility, clickability, presence. A fluent wait is an explicit wait with a configurable polling interval and exceptions to ignore. Explicit waits are the recommended default.

9. Why should you not mix implicit and explicit waits?

Their timeouts can combine unpredictably, producing waits far longer than either value suggests and making failures slow and hard to diagnose. The Selenium documentation advises against mixing them. Most mature frameworks set the implicit wait to zero and rely on explicit waits throughout.

10. Why is Thread.sleep() considered bad practice?

It pauses for a fixed time regardless of whether the element is ready. Too short and the test fails intermittently; too long and the suite wastes time on every run. An explicit wait returns the moment the condition is met, so it is both faster and more reliable.

11. How do you handle dropdowns, alerts and frames?

Standard HTML select dropdowns use the Select class with selectByVisibleText, selectByValue or selectByIndex. JavaScript alerts are handled by switching to the alert and calling accept, dismiss or getText. Frames require switching into the frame by index, name or element before interacting, then switching back to the default content afterwards.

12. How do you handle multiple windows or tabs?

Store the current window handle, perform the action that opens the new window, then iterate through getWindowHandles to find and switch to the new one. Selenium 4 also added a direct way to open a new window or tab and switch to it in one step.

Selenium Interview Questions for Experienced Testers

13. What are the most common Selenium exceptions?

NoSuchElementException when a locator matches nothing, StaleElementReferenceException when the element was re-rendered after you found it, ElementNotInteractableException when it exists but cannot be used, ElementClickInterceptedException when something covers it, and TimeoutException when an explicit wait expires. Being able to explain the cause of each is more valuable than listing them.

14. How do you fix a StaleElementReferenceException?

Re-locate the element after the DOM changes instead of reusing an old reference. Common causes are page refreshes, AJAX updates and single-page-app re-renders. Robust frameworks locate elements fresh at the moment of use, wait for the update to finish, and add a limited retry around known volatile areas rather than blanket retries everywhere.

15. What is the Page Object Model?

A design pattern in which each page or component is represented by a class holding its locators and the actions performed on it. Tests call those methods rather than touching locators directly, so when the UI changes you update one class instead of dozens of tests. It is the standard structure interviewers expect in any framework you describe.

16. What is the difference between Page Object Model and PageFactory?

POM is the design pattern. PageFactory is a Java support class that initialises elements declared with annotations such as @FindBy. Many teams now prefer plain POM with locators held as By objects and located at the moment of use, because it behaves better on dynamic pages where lazily cached elements go stale.

17. How do you design a Selenium framework?

Describe the layers: page objects for UI interaction, tests kept free of locators, a test runner such as TestNG or pytest, configuration and environment handling outside the code, test data separated from test logic, a driver management layer, reporting with screenshots on failure, logging, and CI integration. Interviewers want to hear why each layer exists, not a list of folder names.

18. How do you handle test data in a framework?

Keep it separate from test code — in JSON, CSV, Excel, properties files or a database — and feed it through a data provider or parameterisation so one test runs against multiple data sets. For data that tests create, prefer generating it through APIs and cleaning it up afterwards, so tests do not depend on each other or on a shared, drifting state.

19. What is Selenium Grid and how does Grid 4 differ?

Grid distributes tests across machines, browsers and operating systems so they run in parallel. Grid 4 was rebuilt with a different architecture and can run as a single standalone process, in classic hub-and-node mode, or fully distributed with separate router, distributor, session map and queue components. It also has first-class Docker support, which is how most teams now run it.

20. How do you run tests in parallel?

Configure it at the runner level — TestNG's parallel attribute at methods, classes or tests, or pytest-xdist in Python — and point tests at a Grid or cloud browser provider. The part that matters in the interview is thread safety: each thread needs its own driver instance, typically held in a ThreadLocal, and tests must not share mutable data.

21. What causes flaky tests and how do you reduce them?

Timing issues and fixed sleeps, brittle locators, dependencies between tests, shared test data, unstable test environments, and animations or asynchronous loads the test does not wait for. Fix them with explicit waits on meaningful conditions, stable locators such as dedicated test attributes, independent tests with their own data, and by quarantining and investigating a flaky test rather than simply adding retries until it passes.

22. What changed in Selenium 4?

WebDriver now uses the W3C standard protocol, replacing the older JSON Wire Protocol, which made cross-browser behaviour more consistent. It added relative locators, a direct API for new windows and tabs, element-level screenshots, a rebuilt Grid, and Chrome DevTools and WebDriver BiDi support for network interception and console logs. Selenium Manager now downloads and manages browser drivers automatically.

23. How do you handle Shadow DOM elements?

Standard locators cannot reach inside a shadow root directly. Selenium 4 lets you get the host element and call getShadowRoot, then locate elements within that root using CSS selectors. Before that existed, testers had to fall back on JavaScriptExecutor.

24. When would you use JavaScriptExecutor?

For scrolling to an element, clicking something that native click cannot reach, reading values the DOM does not expose normally, or handling unusual components. It should be the exception, not the habit — a JavaScript click bypasses the checks a real user interaction would go through, so it can hide genuine bugs that users would hit.

25. How do you integrate Selenium with CI/CD?

Build the project with Maven, Gradle or pip, trigger the suite from Jenkins, GitHub Actions or GitLab CI on each commit or on a schedule, run browsers headless or on a Grid, publish reports and failure screenshots as build artefacts, and fail the build on test failures. Mention separating a fast smoke suite on every commit from a full regression run nightly — that trade-off is what interviewers are listening for.

What Interviewers Check at Each Level

AreaFresherExperienced (3+ years)
LocatorsWrite working CSS and XPathChoose stable locators and justify the strategy
WaitsKnow the three typesDiagnose timing-related flakiness
CodeCore Java or Python, loops, collectionsOOP design, thread safety, clean abstractions
FrameworkExplain Page Object ModelDesign one from scratch and defend each layer
ExecutionRun a suite locallyParallel runs, Grid, CI pipelines, reporting

Expect a Live Coding Round

Most automation interviews now include writing code, not just talking about it. For freshers that is usually core programming — reversing a string, finding duplicates in an array, counting word frequency — plus writing a locator for an element on a sample page. For experienced candidates it is typically writing a small page object and a test, or refactoring a badly written one. Practise writing code without an IDE's autocomplete at least a few times, because a shared editor in an interview gives you much less help than you are used to.

Common Mistakes in Selenium Interviews

Answering framework questions with a list of folder names instead of explaining why each layer exists. Saying you use Thread.sleep for synchronisation, which is an instant negative signal. Claiming a framework you cannot draw on a whiteboard. Not knowing the language underneath the tool — many candidates can use Selenium commands but struggle with a basic loop or a HashMap, and the coding round exposes it. And for experienced candidates, describing retries as the fix for flaky tests, when the answer interviewers want is finding and removing the cause.

How Structured Training Helps

Selenium itself is quick to pick up. What takes longer is the programming underneath it, the framework design above it, and the ability to explain both under interview pressure — and those are exactly the areas where self-study gives you the least feedback. Structured training gives you a real framework built end to end, code review on it, and mock interviews that include the live coding round. You can start with ZebLearn India's Software Testing course.

People Also Ask / FAQ

Which language is best for Selenium interviews?

Java is the most common in Indian job listings, with Python a strong second. Use whichever the target company lists, and know it well enough to pass a basic coding round.

Is Selenium still relevant with Playwright and Cypress around?

Yes. Playwright has grown quickly in product teams, but Selenium remains widespread, especially in services companies maintaining large existing suites. Knowing Selenium well and Playwright basics is a strong combination.

Do freshers need to know framework design?

Explaining Page Object Model and having built a small framework yourself is expected. Designing one from scratch in detail is an experienced-level question.

Should I learn API testing alongside Selenium?

Yes. Most automation job descriptions now expect API testing with Postman and RestAssured or a Python equivalent, and interviewers increasingly ask about it.

How should I prepare for a Selenium interview in a week?

Revise locators and waits, practise core programming problems daily, and rehearse a two-minute explanation of a framework you have actually built. Do not cram definitions you cannot explain.

Crack Your Automation Testing Interview

Live classes online and in select cities across India Software Testing Course Details