Skip to content

abra1193/playwright-csharp-nunit-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playwright - Csharp - NUnit Framework

Pipeline workflow

This repository contains a QA automation framework for web pages and API endpoints. The framework is organized for both UI and API automated testing using .NET, NUnit, and Playwright.


Project Structure

qa-automation-exercise--mejiabritoabraham-1.sln         # Solution file
qa-automation-exercise--mejiabritoabraham.csproj        # Project file
README.md                                               # Project documentation

.github/
  workflows/
    dotnet.yml                                          # GitHub Actions CI workflow

Base/
  API/                                                  # Base classes/utilities for API tests
  UI/                                                   # Base classes/utilities for UI tests

Framework/
  API/                                                  # API framework (helpers, clients, etc.)
  UI/                                                   # UI framework (pages, components, etc.)

Shared/
  Constants.cs                                          # Shared constants
  Randomizer.cs                                         # Shared randomization utilities

Tests/
  API/                                                  # API test cases
  UI/                                                   # UI test cases

bin/, obj/                                              # Build output and intermediate files

Getting Started

Prerequisites

  • .NET 6 SDK
  • Node.js (for Playwright installation)
  • Chrome/Edge/Firefox browsers (Playwright will install them automatically)

Setup

  1. Restore dependencies:

    dotnet restore
  2. Install Playwright browsers:

    npx playwright install

Tests

Test Organization

  • UI Tests:
    Located in Tests/UI/. These tests use Playwright to automate browser interactions and validate the product page’s UI and analytics events.

    UI Test Classes & Methods:

    • ProductPageTests
      • ShouldLoadPageMenu
        Verifies that the page menu loads and displays correctly.
      • ShouldLoadPageTitle
        Checks that the page title is present and correct.
      • ShouldDisplayNewsletterSubConfirmationMessage
        Ensures the newsletter subscription confirmation message appears after subscribing.
      • ShouldContainAmazonLinksOnTagParameter
        Checks that Amazon links include the required tag query parameter.
      • ShouldTriggerGoogleAnalyticsEvents
        Validates that Google Analytics events are triggered as expected (e.g., page view, promotion view, promotion select).
      • ShouldContainPromotionIdOnTagParameter
        Ensures that the promotion ID is included in the tag parameter of Amazon links.
  • API Tests:
    Located in Tests/API/. These tests validate the product management API endpoints, including product creation, retrieval, and partner access control.

    API Test Classes & Methods:

    • ProductApiTests
      • ShouldCreateProduct
        Verifies that a product can be created successfully with valid data.
      • ShouldRetrieveProduct
        Checks that a created product can be retrieved and its data is correct.
      • ShouldNotAccessOtherPartnerProducts
        Ensures that a partner cannot access products belonging to another partner.
      • ShouldReturnsBadRequestOnInvalidProductId
        Checks that the API returns a bad request response when the product ID is invalid.
      • ShouldCreateProductWithoutDescription
        Verifies that a product can be created without providing a description.
      • ShouldReturnUnauthorizedWhenPartnerHeaderIsMissing
        Ensures the API returns an unauthorized response if the X-Partner-ID header is missing.

Running Tests

  • All tests:

    dotnet test
  • UI tests only:

    dotnet test --filter Category=UI
  • API tests only:

    dotnet test --filter Category=API

Test Results

  • Test results are displayed in the terminal after execution.
  • For more detailed output or to generate test reports, you can use:
    dotnet test --logger "console;verbosity=detailed"
  • In CI, results are available in the GitHub Actions workflow summary.

Allure Reports

Allure is used to generate rich, interactive test reports.

How to Configure Allure

  1. Install Allure CLI
    You can install Allure globally using Homebrew (recommended for Mac):

    brew install allure

    Or download from Allure Releases.

  2. Add Allure NUnit Adapter
    Add the Allure adapter NuGet package to your project:

    dotnet add package Allure.NUnit
  3. Run Tests with Allure Output
    Run your tests with the Allure logger:

    dotnet test --logger:"allure"

    This will generate results in the allure-results directory.

  4. Generate and View the Report Locally

    allure generate allure-results --clean -o allure-report
    allure open allure-report

    This will open the Allure report in your browser.

Allure Reports in CI

  • Allure results are collected as artifacts in the CI pipeline (see .github/workflows/dotnet.yml).
  • After each CI run, you can download the Allure report artifacts from the GitHub Actions summary page.
  • To view the report locally:
    1. Download the allure-results artifact from the workflow run.
    2. Extract it and run:
      allure generate allure-results --clean -o allure-report
      allure open allure-report

Continuous Integration

GitHub Actions is configured via .github/workflows/dotnet.yml to run tests on push and pull requests.


Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Open a pull request

License

This project is for educational and evaluation purposes only.


Authors

  • Abraham Mejía Brito

About

A sample framework created with CSharp on Playwright with Nunit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages