1. What is the Page Object Model and why use it?
A design pattern with one class per page holding locators and page actions. It reduces duplication, makes tests readable and means a UI change is fixed in one place.
2. What is the difference between POM and PageFactory?
POM is the pattern. PageFactory is a Java helper that initializes @FindBy fields lazily. In Python plain tuples and methods are used. Many Java teams also avoid PageFactory to keep waits explicit.
3. What types of automation frameworks do you know?
| Type | Idea |
|---|---|
| Linear / record-playback | Sequential scripts, hard to maintain |
| Modular | Reusable functions or modules |
| Data-driven | Same test with many data sets from files |
| Keyword-driven | Actions described by keywords in a table |
| BDD | Gherkin scenarios linked to step code |
| Hybrid | Mix of the above (most real projects) |
4. Describe your framework
Good answer outline: language and runner (Python + pytest), conftest.py with a driver factory and options, page objects with a base page, explicit waits, config per environment, secrets in env variables, data from JSON or CSV, markers for smoke and regression, Allure or HTML reports with screenshots on failure, parallel runs with xdist, Docker Grid and GitHub Actions.
5. How do you make tests independent and parallel-safe?
- One driver per test (function-scoped fixture,
ThreadLocalin Java) - Each test creates and cleans its own data
- No shared global state and no test order dependency
- Unique file names for downloads and screenshots
6. What are pytest fixtures? What does yield do?
Fixtures provide setup and teardown for tests via parameters. Code before yield is setup, after yield is teardown, which runs even if the test fails. Scopes: function, class, module, session.
7. What is conftest.py?
A special file where fixtures and hooks are shared automatically with all tests in that folder and below. No import is needed.
8. How do you do data-driven testing?
pytest: @pytest.mark.parametrize with data from CSV or JSON. TestNG: @DataProvider. Behave and Cucumber: Scenario Outline with Examples.
9. How do you run only some tests?
Markers (pytest -m smoke), names (-k login), paths, TestNG groups and testng.xml, Cucumber tags.
10. TestNG annotations order
@BeforeSuite > @BeforeTest > @BeforeClass > @BeforeMethod > @Test > @AfterMethod > @AfterClass > @AfterTest > @AfterSuite.
11. Hard assert vs soft assert
A hard assert stops the test at the first failure. A soft assert (SoftAssert in TestNG) records failures and continues, then reports all at assertAll().
12. How do you run tests in parallel?
Python: pytest -n auto with pytest-xdist. Java: parallel="methods" in testng.xml or parallel DataProvider with a ThreadLocal driver. At scale use Selenium Grid or a cloud provider.
13. What is Selenium Grid and when do you use it?
It routes sessions to browsers on many machines. Use it for cross-browser testing, many parallel tests and clean, repeatable environments (often with Docker). Tests use webdriver.Remote(grid_url, options=...).
14. How do you handle flaky tests?
- Reproduce and capture evidence (screenshot, logs, page source)
- Replace
sleepwith explicit waits - Use stable locators
- Remove dependencies between tests and shared data
- Check environment speed and test data
- Use retries only as a temporary measure and track the flaky tests until fixed
15. How do you handle test data?
Create data through API or database before the test, use unique values, store files in a test_data folder, keep secrets in environment variables or a vault and clean up after the test.
16. How do you integrate Selenium with CI/CD?
A pipeline (GitHub Actions or Jenkins) checks out code, installs dependencies, runs tests headless, publishes JUnit and HTML or Allure reports, uploads screenshots and notifies the team. Smoke tests run on every commit and regression runs nightly.
17. How do you report results?
pytest-html, Allure or ExtentReports, JUnit XML for CI dashboards, plus logs and screenshots on failure.
18. How do you decide what to automate?
Stable, repeated, high-value flows such as login, search and checkout. Avoid frequently changing screens and tests that need human judgment. Follow the test pyramid: many unit and API tests, fewer UI tests.
19. How would you handle login in every test?
Do not click through the UI each time. Log in through the API and place the cookie or token in the browser, or reuse a saved session.
20. How do you handle environment differences?
A config file per environment selected with a variable such as TEST_ENV, base URL and users outside code, secrets from env variables.
21. How do you test on multiple browsers?
A driver factory that reads the browser name from a command line option, a CI matrix, a Grid or a cloud provider such as BrowserStack.
22. How do you keep tests maintainable?
- Page objects and helper methods
- Clear naming and small tests
- Code review for test code
- Weekly review of slow and flaky tests
- Documentation and a good README
23. BDD: when do you use it?
When business people must read and review scenarios. Behave or Cucumber adds a layer to maintain, so skip it when only engineers read the tests.
24. What would you do if a test fails only in CI?
Check the artifacts (screenshot, logs, video), compare browser version, window size (set it in headless mode), timing and environment data. Reproduce locally with the same Docker image.
Conclusion
Show that you understand design: independence, stable locators, clear structure, reporting and CI. Use examples from your own project in your answers.

