How would you design a maintainable Selenium (Java) test automation framework?
Answer
- Stack: Java, JUnit 5 (or TestNG), Selenium WebDriver, Maven, AssertJ, reporting (Allure).
- Structure: Page Object Model; small component classes for shared widgets; tests only describe user steps.
- Stability: stable locators (
data-testid), explicit waits only, no Thread.sleep, retries only for known infrastructure noise. - Data: create test data through the API or database before the test; independent tests that can run in any order and in parallel.
- Execution: headless Chrome in CI (GitHub Actions/Jenkins), Selenium Grid or Docker for parallel and cross-browser runs; screenshots and logs on failure.
- Scope: few E2E flows for critical journeys; the rest at unit and API level.
Practice this question in Repaso