# Selenium, TestNG and API Testing Interview Questions — With Short Answers

Source: https://skills101.in/learn/test-automation/automation-testing-interview-questions — Skills101 free tutorial (Software Testing & Automation). Updated 2026-11-09.

Revise these before QA automation interviews. Answer briefly, then add an example from **your** framework — the one you built in this track.

![The automation pyramid: few UI tests, more API tests, many unit tests](https://skills101.in/learn-img/test-automation/pyramid.svg)

## Testing basics

1. **Verification vs validation?** Built right (reviews, spec) vs right product (running it against user needs).
2. **Smoke vs sanity vs regression?** Smoke: is the build usable at all. Sanity: does this fix work. Regression: did anything else break.
3. **Severity vs priority?** Severity = impact of the bug; priority = how soon to fix it. (A spelling mistake in the company name: low severity, high priority.)
4. **What do you automate first?** Stable, repeated, high-risk flows — login, payments — and the smoke suite.

## Selenium

5. **Selenium WebDriver architecture?** Java client → W3C WebDriver protocol (HTTP/JSON) → browser driver → browser.
6. **findElement vs findElements?** First match or exception vs a list (empty if none).
7. **Best locators?** id, name, `data-testid`, then CSS; XPath for text or parents; never absolute XPath.
8. **Implicit vs explicit wait?** Global retry for every findElement vs waiting for a specific condition; prefer explicit, don't mix.
9. **Why not Thread.sleep?** Always waits the full time and still fails when the app is slower.
10. **StaleElementReferenceException?** The element was re-rendered; find it again.
11. **close() vs quit()?** Current window vs all windows and the session.
12. **Handling alerts, frames, windows?** `switchTo().alert()/frame()/window()`; back with `defaultContent()`.
13. **Dropdowns?** `Select` for `<select>`; click custom dropdowns like normal elements.
14. **Hover or drag-drop?** The `Actions` class with `perform()`.
15. **Screenshots on failure?** `TakesScreenshot` in `@AfterMethod` when the result failed (our `BaseUiTest`).
16. **Headless?** Browser without a window — used on CI servers.
17. **Selenium Manager?** Built-in since 4.6: finds or downloads the right driver automatically.

## TestNG and frameworks

18. **TestNG annotation order?** BeforeSuite → BeforeTest → BeforeClass → BeforeMethod → Test → AfterMethod → AfterClass → AfterTest → AfterSuite.
19. **DataProvider?** Feeds rows of data to one test method; each row is a separate test.
20. **Hard vs soft assert?** Stop at the first failure vs collect failures and report with `assertAll()`.
21. **Groups?** Tags such as smoke and regression to run subsets.
22. **Parallel execution?** `parallel="methods"` in testng.xml, with one WebDriver per test (never a shared static driver).
23. **Listeners?** React to results — logging, screenshots, reporting (`ITestListener`).
24. **What is POM?** One class per page with private locators and user-action methods; tests hold the assertions.
25. **Explain your framework.** Maven + TestNG + Selenium + REST Assured; driver factory, base test, page objects, config via system properties, listeners and reports, CI with GitHub Actions/Jenkins.

## API testing

26. **What do you check in an API test?** Status code, headers, body fields, error messages, response time, and negative cases.
27. **401 vs 403?** Not authenticated vs authenticated but not allowed.
28. **PUT vs PATCH?** Replace the whole resource vs change some fields.
29. **How do you test authenticated APIs?** Log in in the test, extract the token, send it as a Bearer header.
30. **Postman vs REST Assured?** Exploring and sharing without code vs code-based suites in the same repo as UI tests; Newman runs Postman in CI.

## CI and maintenance

31. **How do you run tests in CI?** Start the app, wait for health, run headless with Maven, publish reports and screenshots.
32. **How do you handle flaky tests?** Find the root cause (waits, shared data, parallel state), quarantine meanwhile, don't hide them with retries.

## How to answer well

- Use **your** project: "In my framework, LoginPage.loginAs() returns a DashboardPage, so tests can't act on the wrong page."
- Mention trade-offs: "We check most business rules through the API because UI tests are slower."
- Put the framework on GitHub with a README showing how to run it.

## Common mistakes

- Defining terms without an example.
- Claiming 100% automation is the goal.
- Mixing up implicit/explicit waits or severity/priority.

## Quick recap

- Basics: smoke/sanity/regression, severity vs priority, what to automate.
- Selenium: architecture, locators, explicit waits, stale elements, alerts/frames/windows, Actions.
- TestNG + POM: lifecycle, DataProvider, groups, parallel, listeners, framework layers.
- API + CI: status/body/negative checks, tokens, Postman/Newman, pipelines, flaky tests.


Practice quiz and free certificate: https://skills101.in/learn/test-automation/automation-testing-interview-questions