,

Top 20 Selenium and QA Automation Interview Questions and Answers

By the HiReXL Career Team

Test automation engineers, SDETs and QA engineers are expected to build reliable automated tests that run in CI/CD. These Selenium interview questions and QA automation interview questions cover Selenium WebDriver, locators, waits, framework design, Selenium Grid, flaky tests and API testing.

The top 20 questions and answers below suit manual testers moving into automation as well as experienced automation engineers.

Selenium basics

1. What is Selenium and what are its components?

Selenium is an open-source suite for automating web browsers. It includes Selenium WebDriver (browser automation API), Selenium IDE (record and playback) and Selenium Grid (parallel and distributed execution). It supports Java, Python, C#, JavaScript and Ruby.

2. How does Selenium WebDriver work?

Test code calls WebDriver client libraries, which send W3C WebDriver protocol commands to a browser driver such as ChromeDriver, GeckoDriver or EdgeDriver. The driver controls the real browser and returns results. Selenium Manager now downloads drivers automatically.

3. What locator strategies does Selenium support and which are best?

ID, name, class name, tag name, link text, partial link text, CSS selector and XPath, plus relative locators. Prefer stable IDs, data-test attributes and CSS selectors; use XPath when you need text or complex traversal. Avoid brittle absolute XPaths.

4. What is the difference between findElement and findElements?

findElement returns the first match and throws NoSuchElementException if none exists. findElements returns a list, which is empty when nothing matches, so it is useful for checking presence.

5. Implicit vs. explicit vs. fluent wait?

An implicit wait sets a global timeout for finding elements. An explicit wait (WebDriverWait with ExpectedConditions) waits for a specific condition such as visibility or clickability. A fluent wait adds custom polling intervals and ignored exceptions. Do not mix implicit and explicit waits, and avoid Thread.sleep.

Handling common web elements

6. How do you handle alerts, frames and multiple windows?

Use driver.switchTo().alert() to accept or dismiss alerts, switchTo().frame() by index, name or element for iframes and defaultContent() to return, and getWindowHandles() with switchTo().window() for new tabs or windows.

7. How do you handle dropdowns, mouse actions and keyboard events?

Use the Select class for HTML select dropdowns, and the Actions class for hover, drag and drop, right-click, double-click and key combinations. Custom dropdowns are handled by clicking and choosing option elements.

8. What is StaleElementReferenceException and how do you fix it?

It occurs when a referenced element is no longer attached to the DOM, often after a page refresh or re-render. Re-locate the element, wait for the page or component to stabilize, and avoid caching elements for too long in page objects.

9. How do you take screenshots and handle file uploads?

Use TakesScreenshot to capture screenshots, typically on test failure in a listener. For uploads, send the file path to an input type="file" element with sendKeys; use a local file detector for remote Grid execution.

Frameworks and design

10. What is the Page Object Model?

POM creates one class per page or component that holds locators and actions, so tests read like user steps and locator changes are fixed in one place. Page Factory is an older variant; many teams now use plain page objects or the Screenplay pattern.

11. What types of automation frameworks exist?

Data-driven (test data from Excel, CSV or JSON), keyword-driven, behavior-driven development (Cucumber or SpecFlow with Gherkin), modular and hybrid frameworks combining these. A good framework includes reporting, logging, config management and CI integration.

12. TestNG vs. JUnit?

Both are Java test frameworks. TestNG offers groups, dependencies, data providers, parallel execution and XML suites out of the box. JUnit 5 is modern, extensible and widely used, with parameterized tests and parallel execution. Pick based on team standards.

13. What is Selenium Grid?

Grid runs tests in parallel across machines, browsers and operating systems through a hub (router) and nodes. Teams often run it in Docker or Kubernetes or use cloud providers such as BrowserStack, Sauce Labs or LambdaTest.

14. How do you integrate automated tests into CI/CD?

Run smoke tests on every pull request and full regression nightly or before release using Jenkins, GitHub Actions, GitLab CI or Azure DevOps; run headless browsers in containers; publish reports (Allure, Extent) and fail the build on regressions.

Quality and modern testing

15. What causes flaky tests and how do you fix them?

Common causes are timing issues, shared test data, test order dependencies, unstable environments and brittle locators. Fix with explicit waits, isolated test data, independent tests, stable locators, retries only as a temporary measure, and tracking flaky test rates.

16. How do you test APIs in an automation framework?

Use REST Assured (Java), Postman/Newman, requests with pytest, or Playwright’s API testing. Validate status codes, response schemas, data, headers, auth and error cases. API tests are faster and more stable than UI tests, following the test pyramid.

17. Selenium vs. Playwright vs. Cypress?

Selenium has the widest language and browser support and a large ecosystem. Playwright offers auto-waiting, fast parallel runs, tracing and multi-browser support. Cypress runs in the browser with a great developer experience for JavaScript apps. Choose by stack, team skills and needs.

18. What should and should not be automated?

Automate stable, repetitive, high-value tests: smoke, regression, data-driven and critical user journeys. Keep exploratory, usability, one-off and rapidly changing features manual until they stabilize.

Scenario questions

19. Scenario: your regression suite takes 6 hours. How do you reduce it?

Run tests in parallel on Grid or containers, move logic checks down to API and unit tests, remove duplicate and low-value UI tests, use API calls for test setup instead of UI steps, tag tests into smoke and full suites, and fix slow waits.

20. Scenario: a test passes locally but fails in CI. What do you check?

Browser and driver versions, headless mode and screen size, timing on slower CI agents, environment URLs and test data, missing fonts or locales, and network access. Use screenshots, videos, logs and traces from the CI run to diagnose.

How to prepare for a QA automation interview

  • Build a small framework with Selenium or Playwright, Page Object Model, data-driven tests, reports and a CI pipeline.
  • Practice writing locators for tricky elements and explain your wait strategy.
  • Learn API testing and basic SQL for data validation.
  • Know core testing concepts: test pyramid, regression vs. smoke, severity vs. priority, and the bug lifecycle.

Brush up on code with our Java and Python interview questions, and see DevOps interview questions for CI/CD.

Frequently asked questions

Which language is best for Selenium?

Java is the most common in enterprise job postings, followed by Python, C# and JavaScript. Use the language your target team uses.

Is Selenium still in demand?

Yes. Selenium remains widely used, though Playwright and Cypress are growing. Knowing Selenium plus one modern tool makes you more marketable.

What is an SDET?

A Software Development Engineer in Test writes code to test software, builds automation frameworks and test infrastructure, and works closely with developers on quality.

Got the interview? Make sure your resume tells the same story.

Interviewers read your resume right before they talk to you. HiReXL aligns it with the job description’s keywords so your experience and your answers match. HiReXL is built by 4As Consulting, a cloud and DevOps consulting firm. Looking for your next role? Submit your resume for open positions with PanAmerica Inc.

See how HiReXL helps →