How eliasnogueira/selenium-java-lean-test-architecture works
Project Type and Purpose
• This project is a test automation framework built with Java and Selenium WebDriver. Its purpose is to provide a lean, extendable architecture for web tests that supports multiple execution platforms (local, Selenium Grid, TestContainers) and incorporates industry best practices (Page Object pattern, data factories, parallel execution, logging, reporting, etc.).
• The README clearly outlines the testing strategies and execution types, while the file tree reveals a multi-layered implementation (configuration, driver handling, page objects, data, etc.).
Analyzing the File Structure
• The src/main/java directory is organized in a typical layered manner with packages for config, driver, data, enums, exceptions, model, page, and report – each representing a different facet of the test automation framework.
• The presence of files like grid/docker-compose.yml, configuration properties files, and multiple CI/CD pipeline definitions (.github/workflows, .gitlab-ci.yml, Jenkinsfile) highlight that the project is designed for both local and distributed/parallel executions.
Key Components
a. Test Execution Layer:
• Base Test (BaseWeb class) and TestNG integration that control preconditions (browser creation via annotations) and postconditions (teardown).
• TestListener integration for logging, screenshot capture, and detailed reporting.
b. Driver & Execution Management:
• BrowserFactory: Handles local, remote, and TestContainers browser creation. Represent its methods (createLocalDriver, createDriver, getOptions, createTestContainerDriver) as key decision points.
• DriverManager: Manages WebDriver instances via ThreadLocal storage for parallel execution.
• TargetFactory: Decides the execution type based on configuration (local, selenium-grid, testcontainers) from the properties file.
c. Page Objects and UI Interaction:
• AbstractPageObject and NavigationPage (and other pages under the booking package) that encapsulate web elements and behaviours. Emphasize the Page Object pattern used for the test automation.
d. Data and Configuration:
• Configuration & ConfigurationManager classes for properties handling, separating general and grid-specific configurations.
• BookingDataFactory and the Builder (BookingBuilder) pattern for creating dynamic test data.
• Configuration files (general.properties, grid.properties, log4j2.properties) that abstract test environment and logging settings.
e. Reporting and Logging:
• Allure Report integration (AllureManager, AllureTestLifecycleListener) for test visualization and logging via Log4J2.
Relationships and Interactions
– BaseWeb → TargetFactory determines the execution type → BrowserFactory and/or DriverManager provision the WebDriver instance.
• How the test methods interact with Page Objects (derived from AbstractPageObject) and how these page interactions send commands to the WebDriver.
• Configuration flow: properties loaded via ConfigurationManager, which supplies settings (e.g., timeout, browser, grid.url) to various components.
• That after test execution, the TestListener captures logs and failures, interfacing with Allure for enriched test reports.
• If applicable, note Docker and CI/CD elements:
– Docker grid (grid/docker-compose.yml) and pipeline-as-code components (.github, .gitlab-ci.yml, Jenkinsfile) are used to coordinate parallel/distributed testing.
Detailed Elements
• Each component should have:
– Clear labels (e.g., “BaseWeb (Test Runner)”, “BrowserFactory (Driver Creation)”, “AbstractPageObject (UI Interaction)”).
▸ How test execution flows from BaseWeb to DriverManager and then to the page objects.
▸ How configuration settings are fed from ConfigurationManager to BrowserFactory, etc.
▸ Infrastructure/configuration components versus dynamic test execution components versus external integrations (like Docker or CI pipelines).