# xuannguyen2k4/selenium-test-csharp architecture

> Architecture diagram of the GitHub repository xuannguyen2k4/selenium-test-csharp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xuannguyen2k4/selenium-test-csharp
- Repository: https://github.com/xuannguyen2k4/selenium-test-csharp

## Overview

##### Main Components
- Test Runner and Controller – Represented by Program.cs, which is the entry point that initializes and orchestrates the execution of the tests.
- Test Cases – Individual test classes (LoginTest.cs, NavigationTest.cs, SearchTest.cs) that implement specific testing scenarios (login, search, navigation) including error handling with try-catch.
- Test Web Pages – The SeleniumFrontend folder containing HTML files (login.html, navigation.html, search.html) which serve as the web content that the tests interact with.
- Selenium Automation Layer – The Selenium WebDriver along with ChromeDriver (as shown in the packages section and the presence of chromedriver.exe) that actually drives browser activities.
- Configuration & Dependencies – Files like App.config, packages.config, and dependency folders (e.g., Microsoft.Bcl.AsyncInterfaces, Selenium.WebDriver, Selenium.Support) that support configuration and runtime dependency management.

##### Relationships and Interactions
- The Test Runner (Program.cs) starts the application and sequentially invokes the Test Cases.
- Each Test Case utilizes the Selenium API (via Selenium.WebDriver and Selenium.Support) to launch and control a browser session with ChromeDriver.
- The tests operate on the web pages (the HTML files under SeleniumFrontend) by simulating user interactions (input username, password, search queries, clicking links).
- Configuration settings (from App.config) inform aspects of the test execution such as browser settings and timeouts.
- External dependencies (managed via NuGet packages) are used by the test components to interact with the browser and assist with asynchronous operations, JSON processing, etc.

##### Architectural Patterns and Design Principles
- Modular Test Design – Separation of tests into individual classes for login, search, and navigation encourages maintainability.
- Layered Architecture – Clear separation between test logic (test case files) and the underlying automation driver (Selenium WebDriver/ChromeDriver).
- Dependency Management – Use of NuGet packages to manage third-party libraries keeps the project decoupled from the implementation details.
- Error Handling – Incorporating try-catch blocks in the tests for robust error handling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration & Dependencies"
        G1["App.config"]
        G2["packages.config"]
    end

    A["Program.cs: Application Entry"]
    
    subgraph "Test Cases"
        B["LoginTest.cs: Login Scenario"]
        C["NavigationTest.cs: Navigation Scenario"]
        D["SearchTest.cs: Search Scenario"]
    end

    E["Selenium Automation Layer (WebDriver & ChromeDriver)"]
    
    F["Web Pages (SeleniumFrontend HTML)"]

    %% Arrows for configuration
    G1 --> A
    G2 --> A
    G2 --> E

    %% Program initiates test cases
    A --> B
    A --> C
    A --> D

    %% Test cases utilize Selenium automation layer
    B --> E
    C --> E
    D --> E

    %% Selenium automation layer drives web pages
    E --> F

    %% Click Events
    click A "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/Program.cs"
    click B "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/LoginTest.cs"
    click C "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/NavigationTest.cs"
    click D "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/SearchTest.cs"
    click E "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/bin/Debug/chromedriver.exe"
    click F "https://github.com/xuannguyen2k4/selenium-test-csharp/tree/master/SeleniumTesting/SeleniumFrontend"
    click G1 "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/App.config"
    click G2 "https://github.com/xuannguyen2k4/selenium-test-csharp/blob/master/SeleniumTesting/packages.config"

    %% Styles
    classDef runner fill:#cce5ff,stroke:#1e90ff,stroke-width:2px,color:#000000;
    classDef testcase fill:#ffedcc,stroke:#ffa500,stroke-width:2px,color:#000000;
    classDef selenium fill:#d4edda,stroke:#28a745,stroke-width:2px,color:#000000;
    classDef webpage fill:#fff3cd,stroke:#ffc107,stroke-width:2px,color:#000000;
    classDef config fill:#e2d6f3,stroke:#6f42c1,stroke-width:2px,color:#000000;

    class A runner;
    class B,C,D testcase;
    class E selenium;
    class F webpage;
    class G1,G2 config;
```
