# vikashchauhan51/playwrightsample architecture

> Architecture diagram of the GitHub repository vikashchauhan51/playwrightsample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikashchauhan51/playwrightsample
- Repository: https://github.com/vikashchauhan51/playwrightsample

## Overview

##### Project type and purpose
- This is a C#-based test automation framework skeleton using Playwright.
- Its purpose is to provide a Page Object Model (POM)–style structure for writing and running browser tests.

##### File structure
- Top-level folders:
- Core – bootstrap and Playwright configuration (PlaywrightConfiguration.cs)
- Pages – Page Object classes (PageBase.cs, SearchPage.cs)
- Tests – test definitions and base test setup (TestBase.cs, SampleTest.cs)
- Utils – utility helpers for file and JSON reading (FileReader.cs, JsonReader.cs)
- Extensions – extension methods used across the framework
- Config files: configuration.json (holds test settings), nlog.config (logging), playwright.ps1 installer script
- Project files: .csproj, .sln

##### README for additional insights
- Confirms POM structure (Core, Pages, Tests, Utils)
- Requires VS 2022, Git, Playwright CLI install
- No heavyweight microservices or external APIs—tests drive a browser via Playwright

##### Main components
a. Test Runner Layer
– MSTest / NUnit / xUnit (inferred from TestBase) executes tests in Tests folder
b. Tests Layer
– SampleTest.cs calls methods on Page Objects
c. Page Objects Layer
– Pages/PageBase.cs defines common page behavior
– Pages/SearchPage.cs implements specific UI operations
d. Core Framework Layer
– Core/PlaywrightConfiguration.cs initializes Playwright, launches browser/contexts
e. Utilities & Extensions
– Utils/FileReader.cs, Utils/JsonReader.cs read config and test data
– Extensions/ObjectExtensions.cs adds helper methods
f. Configuration Source
– configuration.json drives environment/browser settings
g. External Service
– Playwright (node-based driver launching actual browser)
h. Logging
– nlog.config for test execution logs

##### Relationships and data flow
1. Test Runner triggers TestBase (Tests/TestBase.cs)
2. TestBase reads configuration.json via JsonReader/FileReader
3. PlaywrightConfiguration sets up browser instances
4. Tests instantiate Page Objects, call methods on SearchPage/PageBase
5. Page Objects execute actions through Playwright driver
6. Playwright communicates with actual browser (Chromium/WebKit/Firefox)
7. Test results and logs (via NLog) flow back to Test Runner

##### Architectural patterns and principles
- Layered architecture (Tests → Pages → Core → Playwright)
- Page Object Model (POM) encapsulates UI interactions
- Dependency injection (TestBase provides PlaywrightConfiguration to Pages)
- Single responsibility (Utils only handle file/JSON I/O; Extensions only add helpers)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Test Runner Layer
    subgraph "Test Runner Layer"
        TR["Test Runner (MSTest/NUnit)"]:::tests
        TB["TestBase.cs"]:::tests
        ST["SampleTest.cs"]:::tests
    end

    %% Page Objects Layer
    subgraph "Page Objects Layer"
        PB["PageBase.cs"]:::pages
        SP["SearchPage.cs"]:::pages
    end

    %% Core Framework Layer
    subgraph "Core Framework Layer"
        PC["PlaywrightConfiguration.cs"]:::core
    end

    %% Utilities & Extensions
    subgraph "Utilities & Extensions"
        FR["FileReader.cs"]:::utils
        JR["JsonReader.cs"]:::utils
        OE["ObjectExtensions.cs"]:::utils
    end

    %% Configuration Source
    subgraph "Configuration Source"
        CFG["configuration.json"]:::config
        NLOG["nlog.config"]:::config
    end

    %% External Service
    EXTERNAL["Playwright Driver & Browser"]:::external

    %% Relationships
    TR --> TB
    TR --> ST
    TB --> JR
    TB --> FR
    JR --> CFG
    FR --> CFG
    TB --> PC
    ST --> PB
    ST --> SP
    PB --> PC
    SP --> PC
    PC --> EXTERNAL
    ST --> NLOG

    %% Click Events
    click TB "https://github.com/vikashchauhan51/playwrightsample/blob/master/Tests/TestBase.cs"
    click ST "https://github.com/vikashchauhan51/playwrightsample/blob/master/Tests/SampleTest.cs"
    click PB "https://github.com/vikashchauhan51/playwrightsample/blob/master/Pages/PageBase.cs"
    click SP "https://github.com/vikashchauhan51/playwrightsample/blob/master/Pages/SearchPage.cs"
    click PC "https://github.com/vikashchauhan51/playwrightsample/blob/master/Core/PlaywrightConfiguration.cs"
    click FR "https://github.com/vikashchauhan51/playwrightsample/blob/master/Utils/FileReader.cs"
    click JR "https://github.com/vikashchauhan51/playwrightsample/blob/master/Utils/JsonReader.cs"
    click OE "https://github.com/vikashchauhan51/playwrightsample/blob/master/Extensions/ObjectExtensions.cs"
    click CFG "https://github.com/vikashchauhan51/playwrightsample/blob/master/configuration.json"
    click NLOG "https://github.com/vikashchauhan51/playwrightsample/blob/master/nlog.config"

    %% Styles
    classDef tests fill:#BBDEFB,stroke:#1E88E5,color:#1E88E5
    classDef pages fill:#C8E6C9,stroke:#43A047,color:#2E7D32
    classDef core fill:#FFE0B2,stroke:#FB8C00,color:#E65100
    classDef utils fill:#FFF9C4,stroke:#FBC02D,color:#F57F17
    classDef config fill:#E1BEE7,stroke:#8E24AA,color:#6A1B9A
    classDef external fill:#CFD8DC,stroke:#546E7A,color:#37474F
```
