Selenium Testing & Quality Assurance 2 — Questions and Answers
Question 1: Which testing type verifies that a new code change does not break existing functionality?
- Smoke testing
- Regression testing (Correct answer)
- Exploratory testing
- Boundary testing
Correct answer: Regression testing
Regression testing re-runs previously passing tests to confirm existing features still work after code changes.
Question 2: In a Selenium test suite, what is the purpose of a Page Object Model (POM)?
- To speed up test execution
- To encapsulate page UI elements and interactions into reusable classes (Correct answer)
- To generate test reports automatically
- To manage browser driver versions
Correct answer: To encapsulate page UI elements and interactions into reusable classes
POM separates page-specific locators and actions into dedicated classes, improving test maintainability and reducing duplication.
Question 3: What does a 'flaky' test mean in the context of automated testing?
- A test that always fails
- A test that never runs
- A test that intermittently passes or fails without code changes (Correct answer)
- A test with no assertions
Correct answer: A test that intermittently passes or fails without code changes
Flaky tests produce inconsistent results across runs due to timing issues, race conditions, or environmental instability.
Question 4: Which Selenium WebDriver method is best suited to verify that an element is NOT present on the page?
- driver.findElement()
- driver.findElements() and check size == 0 (Correct answer)
- driver.assertNotPresent()
- driver.getElementById()
Correct answer: driver.findElements() and check size == 0
findElements() returns an empty list rather than throwing an exception when no matching elements are found, making it safe for absence checks.
Question 5: What is the primary goal of smoke testing in QA?
- Verify all edge cases
- Confirm the build is stable enough for deeper testing (Correct answer)
- Test performance under load
- Validate database integrity
Correct answer: Confirm the build is stable enough for deeper testing
Smoke testing runs a minimal set of critical tests to determine whether a build is worth further, more extensive testing.
Question 6: In test automation, what does 'test coverage' measure?
- The number of testers on the team
- The proportion of application functionality or code exercised by tests (Correct answer)
- The speed of test execution
- The number of defects found
Correct answer: The proportion of application functionality or code exercised by tests
Test coverage quantifies how much of the application's code or functionality is exercised by the existing test suite.
Question 7: Which practice helps prevent Selenium tests from being brittle due to dynamic element IDs?
- Use XPath with absolute paths
- Use CSS selectors based on dynamic IDs
- Use stable attributes like data-testid or aria-label (Correct answer)
- Use thread.sleep() before each action
Correct answer: Use stable attributes like data-testid or aria-label
Stable, semantically meaningful attributes like data-testid are not auto-generated and remain consistent across builds, making locators reliable.
Which testing type verifies that a new code change does not break existing functionality?