Selenium System Architecture & Design 2 — Questions and Answers
Question 1: In a Selenium Grid 4 architecture, what is the primary role of the Distributor node?
- Execute test scripts directly on browsers
- Assign test sessions to available nodes based on capabilities (Correct answer)
- Store browser driver binaries for distribution
- Monitor node health and restart failed sessions
Correct answer: Assign test sessions to available nodes based on capabilities
The Distributor receives session requests from the Router and assigns them to the appropriate Node that matches the requested capabilities.
Question 2: Which design pattern is most commonly used to represent web pages as objects with methods in a Selenium framework?
- Factory Pattern
- Singleton Pattern
- Page Object Model (POM) (Correct answer)
- Observer Pattern
Correct answer: Page Object Model (POM)
The Page Object Model (POM) encapsulates web page elements and interactions into dedicated classes, improving maintainability and reducing code duplication.
Question 3: When designing a Selenium framework for parallel execution, what is the main reason to use ThreadLocal<WebDriver>?
- To share a single WebDriver instance across all threads
- To ensure each thread has its own isolated WebDriver instance (Correct answer)
- To reduce memory usage by pooling WebDriver connections
- To synchronize WebDriver actions between parallel tests
Correct answer: To ensure each thread has its own isolated WebDriver instance
ThreadLocal<WebDriver> provides each thread with its own WebDriver instance, preventing interference between concurrently executing tests.
Question 4: In a layered Selenium test architecture, which layer is responsible for holding business logic and test flow?
- WebDriver Layer
- Page Object Layer
- Test Layer (Correct answer)
- Utility Layer
Correct answer: Test Layer
The Test Layer contains test methods that orchestrate business flows by calling Page Object methods, keeping test intent separate from implementation details.
Question 5: What is the architectural benefit of using a Base Page class in a Page Object Model framework?
- It removes the need for explicit waits across all tests
- It centralizes common WebDriver interactions and wait logic for all page objects to inherit (Correct answer)
- It stores test data and configuration properties
- It manages browser instantiation and teardown lifecycle
Correct answer: It centralizes common WebDriver interactions and wait logic for all page objects to inherit
A Base Page class provides shared methods like element clicking, typing, and waiting that all page objects inherit, eliminating code duplication.
Question 6: In Selenium Grid, when a Node registers with the Hub (Grid 3) or Router (Grid 4), what information does it send?
- List of test scripts available for execution
- Its capabilities including browser type, version, and OS platform (Correct answer)
- The current CPU and memory utilization metrics only
- Authentication credentials for secure communication
Correct answer: Its capabilities including browser type, version, and OS platform
Nodes advertise their capabilities (browser name, version, OS) to the Hub/Router so it can match incoming session requests to appropriate nodes.
Question 7: Which architectural approach allows a Selenium framework to switch between different browsers without changing test code?
- Hardcoding browser instantiation in every test class
- Using a Driver Factory that reads browser type from a configuration file or system property (Correct answer)
- Creating separate test suites for each browser
- Storing WebDriver instances in a static global variable
Correct answer: Using a Driver Factory that reads browser type from a configuration file or system property
A Driver Factory pattern reads a browser parameter at runtime and returns the appropriate WebDriver, making tests browser-agnostic.
In a Selenium Grid 4 architecture, what is the primary role of the Distributor node?