Selenium Testing Framework Research & Evidence-Based Practice 3 — Questions and Answers
Question 1: Which study-backed Selenium practice recommends taking screenshots only on test failure rather than on every step?
- Continuous Screenshotting
- Selective Evidence Capture (Correct answer)
- Visual Regression Testing
- Screenshot-Driven Development
Correct answer: Selective Evidence Capture
Research shows capturing screenshots only on failure reduces disk I/O, speeds suite execution, and provides focused diagnostic evidence without noise.
Question 2: What does evidence-based test design recommend regarding Selenium test atomicity?
- Tests should share state across methods for speed
- Each test should set up and tear down its own state independently (Correct answer)
- Tests should run in strict alphabetical order
- State should be persisted in static variables between tests
Correct answer: Each test should set up and tear down its own state independently
Atomic tests that are fully independent prevent cascading failures and produce reliable, reproducible results as supported by software testing research.
Question 3: Research into Selenium's WebDriverWait reveals that combining ExpectedConditions with a polling interval accomplishes what?
- Forces synchronous page load before checking
- Periodically checks a condition rather than sleeping for the full timeout (Correct answer)
- Disables implicit waits automatically
- Speeds up JavaScript execution in the browser
Correct answer: Periodically checks a condition rather than sleeping for the full timeout
WebDriverWait polls the ExpectedCondition at a configurable interval, returning as soon as the condition is met instead of waiting the full timeout duration.
Question 4: Evidence from large-scale Selenium deployments shows that running tests in parallel primarily reduces which resource?
- CPU cycles per test
- Total wall-clock execution time (Correct answer)
- Number of assertions needed
- Browser driver download size
Correct answer: Total wall-clock execution time
Parallel execution distributes tests across multiple browser sessions simultaneously, dramatically cutting the total calendar time required to run the full suite.
Question 5: Which evidence-based recommendation applies when Selenium tests need to verify dynamic content that changes on every page load?
- Assert exact string matches
- Use regular expressions or partial text matching with contains() (Correct answer)
- Disable JavaScript during the test
- Reload the page multiple times before asserting
Correct answer: Use regular expressions or partial text matching with contains()
For dynamic content, research recommends flexible assertions using partial matching or regex patterns to avoid brittle tests that fail on minor, expected variations.
Question 6: Studies on Selenium 4's relative locators demonstrate their primary research-backed use case is what?
- Replacing all XPath expressions
- Locating elements by their spatial relationship to a known anchor element (Correct answer)
- Improving cross-browser CSS parsing
- Automating shadow DOM traversal
Correct answer: Locating elements by their spatial relationship to a known anchor element
Relative locators (toLeftOf, toRightOf, above, below, near) are designed to find elements based on their visual position relative to another element on the page.
Question 7: According to software testing research, what is the recommended maximum number of assertions per Selenium test to maintain diagnostic clarity?
- One assertion per test (single assertion principle) (Correct answer)
- Exactly three assertions
- As many as needed to validate the full feature
- No more than ten assertions
Correct answer: One assertion per test (single assertion principle)
The single assertion principle, supported by research, recommends one logical assertion per test so that a failure immediately identifies the broken behavior without ambiguity.
Which study-backed Selenium practice recommends taking screenshots only on test failure rather than on every step?