How anhtester/playwrightjava works
Main Components
• Test Runner & Framework: At the heart of the project is the TestNG framework (used for executing test suites) which drives the test cases found under the “src/test” directory. This includes test classes, listeners (like AllureListener and TestListener), and suite XML configurations.
• Page Object Model (POM): Under “src/test/java/com/anhtester/pom/”, page classes (e.g., BasePage, and other page implementations for admin and user scenarios) are implemented using the POM design pattern. This abstraction clearly separates the UI interactions from the test logic.
• Browser and Test Managers: The “src/main/java/com/anhtester/managers” directory indicates dedicated managers like BrowserFactory (for browser session management) and PageManager (for handling page objects).
• Helper and Utility Modules: The project contains various helper classes (e.g., CaptureHelper, ExcelHelper, FileHelper, PropertiesHelper, and SystemHelper) under “src/main/java/com/anhtester/helpers” and utilities like LogUtils. These facilitate various cross-cutting concerns such as file operations, properties configuration, and logging.
• Reporting & Logging: Reporting is managed via classes like AllureManager, ExtentReportManager, and ExtentTestManager within “src/main/java/com/anhtester/reports”. Also, note that a log4j2.properties file in “src/main/resources” establishes the logging configuration.
• Configuration and Data Resources: The “src/test/resources” directory holds configuration files (config.properties) along with test data (like data.json) and suite configurations (Suite XML files). There is also a Maven pom.xml at the top-level for dependency management and build configuration.
Relationships and Interactions
• Helper & Utility Integration: The Test cases and page objects leverage helper modules for common functions (capturing screenshots, managing Excel data, file operations, etc.). Show these as supportive components linked with general utilities.
Important Architectural Patterns and Design Principles
• Page Object Model (POM): Emphasize how the project abstracts web page functionalities behind dedicated Page classes.
• Layered Architecture: Distinguish between test cases, page objects, managers, helpers, and reporting. Each layer has a distinct responsibility which minimizes coupling.
• Modular and Extensible Design: The use of dedicated helper classes and managers implies that each component can be maintained or extended independently.