Selenium WebDriver Research & Evidence-Based Practice 5 β Questions and Answers
Question 1: Evidence-based research on shadow DOM testing with Selenium 4 shows that which method correctly accesses elements inside a shadow root?
- driver.findElement(By.cssSelector('::shadow .inner-element'))
- Expanding the shadow root via getShadowRoot() on the host element, then chaining findElement()
- Using driver.executeScript('return document.querySelector(".host").shadowRoot.querySelector(".inner")')
- Both B and C are validated approaches (Correct answer)
Correct answer: Both B and C are validated approaches
Selenium 4's getShadowRoot() and direct JavaScript execution are both documented, supported methods for piercing shadow DOM boundaries.
Question 2: Research comparing 'record and playback' automation tools to code-based Selenium frameworks consistently finds that code-based frameworks excel at:
- Faster initial test creation speed for non-programmers
- Scalability, reusability, and integration with version control systems (Correct answer)
- Lower barrier to entry for manual testers
- Generating visual diff reports automatically
Correct answer: Scalability, reusability, and integration with version control systems
Code-based frameworks produce maintainable, versionable artifacts that support refactoring, abstraction, and CI integration at scale.
Question 3: Studies on mobile web testing with Selenium recommend using which configuration to accurately simulate touch-based interactions on desktop Chrome?
- Switching to the HtmlUnit driver which natively supports touch events
- Using ChromeOptions to add a mobile emulation device configuration (Correct answer)
- Installing a separate Selenium mobile extension
- Running tests inside a Docker container with a virtual touchscreen
Correct answer: Using ChromeOptions to add a mobile emulation device configuration
Chrome's DevTools mobile emulation mode, activated via ChromeOptions, replicates viewport size and touch event handling for mobile browsers.
Question 4: Evidence-based API testing research recommends combining Selenium UI tests with RestAssured or similar libraries because:
- Selenium cannot test REST APIs natively, and API-level tests validate backend contracts faster (Correct answer)
- RestAssured replaces the need for a WebDriver session entirely
- API tests run through the browser rendering engine for accuracy
- Combining them reduces total test count below 50
Correct answer: Selenium cannot test REST APIs natively, and API-level tests validate backend contracts faster
API tests run orders of magnitude faster than UI tests and validate business logic independently of rendering, complementing Selenium's UI coverage.
Question 5: Research on continuous visual regression testing with Selenium shows that pixel-by-pixel screenshot comparison is unreliable because:
- Selenium cannot capture full-page screenshots on headless browsers
- Minor rendering differences (font hinting, anti-aliasing) across environments produce false positives (Correct answer)
- Pixel comparison requires a premium Selenium Grid license
- Screenshots captured by Selenium omit CSS pseudo-elements
Correct answer: Minor rendering differences (font hinting, anti-aliasing) across environments produce false positives
Rendering engines produce sub-pixel differences across OS and GPU combinations, so pixel-exact comparison generates noise unrelated to actual UI regressions.
Question 6: Evidence from test automation maturity model research places which practice at the highest maturity level for Selenium teams?
- Running Selenium tests manually before each release
- Self-healing tests that automatically update locators when minor DOM changes are detected (Correct answer)
- Writing tests in a single large class file for simplicity
- Using only ID-based locators across the entire suite
Correct answer: Self-healing tests that automatically update locators when minor DOM changes are detected
Self-healing automation uses AI or heuristic fallback locators to adapt to UI changes without human intervention, representing advanced automation maturity.
Question 7: Based on WebDriver BiDi (bidirectional protocol) research, which new capability does it provide that classic WebDriver JSON Wire Protocol lacks?
- Ability to click elements inside iframes
- Real-time event subscription for console logs, network requests, and DOM mutations without polling (Correct answer)
- Support for running tests on Internet Explorer
- Headless browser execution without a display server
Correct answer: Real-time event subscription for console logs, network requests, and DOM mutations without polling
BiDi's bidirectional channel lets the browser push events to the test in real time, replacing fragile polling-based workarounds for dynamic event capture.
Evidence-based research on shadow DOM testing with Selenium 4 shows that which method correctly accesses elements inside a shadow root?