Selenium Interview Questions for Freshers (2026): 35 Questions with Clear Answers

Short answer: most Selenium interviews for freshers test five areas: Selenium basics (what WebDriver is and what it cannot do), locators and XPath, waits and synchronisation, common exceptions, and frameworks (TestNG and the Page Object Model). Expect at least one scenario question, such as handling a dropdown, an alert or a new tab, and a short coding task in Java. The answers below are written the way you should say them in an interview: short, correct and backed by an example.

This guide assumes Selenium 4 with Java, which is what most Indian QA job descriptions ask for. If you are still choosing a tool, read Selenium vs Playwright first. If you are new to testing, start with manual vs automation testing for freshers.

Selenium basics

1. What is Selenium?

Selenium is an open-source suite for automating web browsers. Its main component, Selenium WebDriver, drives real browsers such as Chrome, Firefox, Edge and Safari through the W3C WebDriver standard. It supports Java, Python, C#, JavaScript and Ruby.

2. What are the components of Selenium?

Selenium WebDriver (browser automation API), Selenium IDE (a record-and-playback browser extension) and Selenium Grid (runs tests in parallel on many machines and browsers).

3. What is new in Selenium 4?

Full W3C WebDriver compliance, relative locators such as above() and near(), a new window and tab API, element-level screenshots, a redesigned Grid, and Selenium Manager, which downloads the right browser driver automatically so you no longer need to manage chromedriver yourself. Newer releases also add WebDriver BiDi support for features such as listening to console logs and network events.

4. What can Selenium not do?

It automates browsers only. It cannot test desktop or native mobile apps on its own (Appium is used for mobile), cannot solve CAPTCHAs by design, cannot read OTPs from your phone, and has no built-in reporting or test management. You add TestNG or JUnit for test structure and a library such as Extent Reports for reports.

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

close() closes the current window. quit() closes all windows and ends the WebDriver session. Always call quit() in your teardown so browser processes do not pile up.

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

Both open a URL and wait for the page to load. navigate() also gives you back(), forward() and refresh().

Locators and XPath

7. Which locators does Selenium support?

id, name, className, tagName, linkText, partialLinkText, cssSelector and xpath, plus relative locators in Selenium 4. Prefer a unique id or a stable data attribute (for example data-test), then CSS, then XPath.

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

Absolute XPath starts from the root (/html/body/div[2]/...) and breaks whenever the layout changes. Relative XPath starts with // and finds the element by its attributes or text, for example //button[text()='Login'], so it is far more stable.

9. How do you handle dynamic elements whose ids change?

Use attributes that stay the same, or partial matches: //input[contains(@id,'email')], //a[starts-with(@id,'order_')], or axes such as //label[text()='Email']/following-sibling::input.

10. CSS selector or XPath: which is better?

CSS selectors are short and readable. XPath can do things CSS cannot, such as finding an element by its visible text or moving up to a parent. Use CSS by default and XPath when you need text or parent and sibling navigation.

11. What is the difference between findElement() and findElements()?

findElement() returns the first match and throws NoSuchElementException if there is none. findElements() returns a list, which is empty if nothing matches, so it is useful for checking whether an element exists.

Waits and synchronisation

12. What types of waits are there?

Wait How it works When to use
Implicit wait A global timeout for every findElement call Rarely, and never mixed with explicit waits
Explicit wait (WebDriverWait) Waits for a specific condition on a specific element Most cases: clickable buttons, visible messages, page changes
Fluent wait An explicit wait with custom polling interval and ignored exceptions Elements that appear unpredictably
Thread.sleep() Pauses for a fixed time whatever happens Avoid in real frameworks: it makes tests slow and still flaky
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement login = wait.until(ExpectedConditions.elementToBeClickable(By.id("login")));
login.click();

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

The Selenium documentation warns that mixing them can cause unpredictable wait times, because both timeouts can apply to the same lookup. Pick explicit waits and keep the implicit wait at zero.

Common exceptions

14. What is a StaleElementReferenceException and how do you fix it?

It means the element you stored is no longer attached to the page, usually because the page or that part of the DOM was refreshed. Find the element again just before using it, or wait for the refresh to finish.

15. Which other exceptions do you see often?

NoSuchElementException (wrong locator or element not loaded yet), ElementClickInterceptedException (another element such as a popup covers it), ElementNotInteractableException (element is hidden or disabled), TimeoutException (an explicit wait condition never became true) and NoSuchFrameException.

Handling common web elements

16. How do you handle a dropdown?

For a standard <select> element, use the Select class: new Select(element).selectByVisibleText("India"), or selectByValue() and selectByIndex(). Custom dropdowns built from divs are clicked like normal elements.

17. How do you handle alerts?

Alert alert = driver.switchTo().alert();
String msg = alert.getText();
alert.accept();   // or alert.dismiss(); alert.sendKeys("text");

18. How do you work with frames?

Switch into the frame with driver.switchTo().frame() by index, name or id, or WebElement, then return with driver.switchTo().defaultContent().

19. How do you handle multiple windows or tabs?

Store the original handle with getWindowHandle(), loop through getWindowHandles() and switch to the new one. In Selenium 4 you can open a new tab directly with driver.switchTo().newWindow(WindowType.TAB).

20. How do you perform mouse hover, drag and drop or right-click?

Use the Actions class: new Actions(driver).moveToElement(menu).perform(), dragAndDrop(source, target) and contextClick(element).

21. When do you use JavascriptExecutor?

To scroll an element into view, read values a normal call cannot reach, or as a last resort to click an element. Do not use it to hide real problems: if a user cannot click a button, your test should fail.

22. How do you take a screenshot?

Cast the driver to TakesScreenshot and call getScreenshotAs(OutputType.FILE). In Selenium 4 you can also screenshot a single WebElement. Frameworks usually take a screenshot automatically when a test fails.

23. How do you run tests in headless mode?

Set a browser option, for example options.addArguments("--headless=new") for Chrome. Headless runs are common in CI pipelines.

TestNG and frameworks

24. Why use TestNG with Selenium?

Selenium only drives the browser. TestNG adds test structure: annotations, assertions, grouping, priorities, dependencies, data providers, parallel execution through testng.xml and HTML reports.

25. What is the execution order of TestNG annotations?

@BeforeSuite → @BeforeTest → @BeforeClass → @BeforeMethod → @Test → @AfterMethod → @AfterClass → @AfterTest → @AfterSuite.

26. How do you do data-driven testing?

Use a TestNG @DataProvider that returns rows of test data, often read from Excel (Apache POI), CSV or JSON, so the same test runs with many inputs.

27. What is the Page Object Model?

A design pattern where each page gets its own class holding its locators and actions, such as LoginPage.login(user, pass). Tests call these methods instead of using locators directly, so a UI change is fixed in one place. PageFactory with @FindBy is one way to initialise page elements.

28. What is a hybrid framework?

A framework that combines approaches, usually Page Object Model plus data-driven testing, often with keyword or BDD layers, built with Maven, TestNG, a reporting library and logging such as Log4j.

29. What is BDD with Cucumber?

Behaviour-driven development writes scenarios in plain-English Gherkin (Given, When, Then) that business people can read. Step definitions in Java connect each step to Selenium code.

30. What is Selenium Grid?

Grid runs tests on remote machines and many browser versions in parallel. You point a RemoteWebDriver at the Grid URL. Grid 4 can run as a single standalone server or as separate components for larger setups.

31. How do you run Selenium tests in CI?

Package the framework with Maven, then trigger mvn test from Jenkins or GitHub Actions on each commit or on a schedule, usually in headless mode or against a Grid, and publish the reports.

Scenario and coding questions

32. How would you automate a login test?

Open the page, enter valid credentials, click login, and assert something only a logged-in user sees, such as the account name. Then add negative cases: wrong password, empty fields and a locked account, each checking the right error message.

33. How do you verify all links on a page are working?

Collect findElements(By.tagName("a")), read each href, send an HTTP request with Java’s HttpClient and flag status codes of 400 or above. Selenium alone cannot read HTTP status codes.

34. A test passes locally but fails in CI. What do you check?

Timing (replace sleeps with explicit waits), screen size in headless mode, test data shared between parallel tests, environment URLs and credentials, and browser or driver versions.

35. Write code to print all options of a dropdown.

Select country = new Select(driver.findElement(By.id("country")));
for (WebElement option : country.getOptions()) {
    System.out.println(option.getText());
}

How to prepare in the last week

  1. Revise core Java: OOP, collections, exception handling and string programs. Many Selenium rounds start with Java questions.
  2. Rebuild one small framework from scratch: Maven, TestNG, Page Object Model, a data provider and a report.
  3. Practise ten locators on a real site and explain why you chose each one.
  4. Prepare a two-minute walkthrough of your project: what you automated, your framework design and one flaky test you fixed.
  5. Revise testing basics too. Our manual testing interview questions cover what interviewers ask before the automation round.

For broader interview preparation, see our tech interview preparation guide, and learn how AI assistants speed up script writing in using AI for Selenium test scripts.

Learn Selenium automation at TryCatch Classes

TryCatch Classes’ Selenium Automation Training with AI covers core Java, locators, WebDriver, JUnit and TestNG, database testing, Log4j, Maven, BDD with Cucumber, Extent Reports, data-driven, keyword-driven and hybrid frameworks, and the Page Object Model, with live projects and interview preparation. For the full QA path, choose Software Testing Training. Learn at our Borivali West classroom or live online, with a 100% placement guarantee.

A note from Mehul Prajapati, Founder, TryCatch Classes

I have spent 18+ years in IT and training and have personally mentored 12,000+ students. If you are planning your next step in Selenium automation and want a second opinion on your learning path, I am happy to help.

“The technology you learn today may change tomorrow, but your ability to learn will always be your biggest strength. Stay curious, keep upgrading yourself, and never stop growing.”

Message me on WhatsApp at +91 99301 12627 and tell me which blog you read. I would love to hear from you.

Frequently asked questions

Is Selenium still in demand in 2026?

Yes. Selenium with Java remains one of the most common skills in Indian QA job descriptions, especially in services companies and banks with large existing test suites, even as Playwright grows in newer projects.

Which language is best for Selenium interviews?

Java is the most requested in India, followed by Python. Pick one and learn it well enough to write string, array and collection programs without help.

Do freshers need to know Selenium Grid?

You should be able to explain what Grid does and how RemoteWebDriver connects to it. Deep Grid setup is rarely expected from freshers.

How many Selenium questions are asked in a fresher interview?

It varies, but a typical technical round mixes 10 to 20 Selenium and Java questions with one or two coding tasks and questions about your project.

Cover image: photo by Mohammad Rahmani on Unsplash.

Related Training Courses