This project is a comprehensive Quality Assurance & Testing solution developed as a lab assignment. It performs End-to-End (E2E) automated testing on Swag Labs (SauceDemo).
The framework is built using C# and Selenium WebDriver, implementing the Page Object Model (POM) design pattern to ensure maintainability, readability, and scalability. It includes advanced features such as HTML reporting, configuration management via JSON, and automatic screenshot capture on failure.
- Language: C# (.NET 8.0)
- Automation Tool: Selenium WebDriver
- Browser: Google Chrome (configured via options)
- Test Framework: NUnit
- Reporting: ExtentReports (HTML Reports)
- Configuration: Microsoft.Extensions.Configuration (JSON)
- Waits: Selenium Extras
ExpectedConditions(Explicit Waits)
The project is structured to separate the Test Logic from the UI Elements/Actions.
Pages/Directory: Contains classes representing web pages (LoginPage,InventoryPage,CartPage,Checkout*Page). These classes handle element locators and user interactions.Tests/Directory: Contains the actual test assertions. These classes do not interact with the browser directly; they call methods from the Page classes.BaseTest&BasePage: Handles common setup (Browser initialization, Reporting, Teardown) and generic actions (Click, Type, Wait).
- Data-Driven Testing: Uses NUnit
[TestCase]to validate multiple login scenarios (Standard, Problem, Error, Visual users) in a single run. - Robust Configuration: Uses
appsettings.jsonto manage credentials, URLs, and browser settings without hardcoding. - HTML Reporting: Generates detailed execution reports in the
Reports/folder. - Failure Analysis: Automatically captures and embeds screenshots into the report when a test fails.
The framework covers scenarios for various user types provided by SauceDemo:
- Type: Happy Path Testing.
- Scenarios:
- Successful login.
- Inventory sorting (Price, Name).
- Adding/Removing items from the cart.
- Cart persistence validation.
- Full checkout process (Information input -> Tax calculation verification -> Completion).
- Social Media footer link verification.
- Logout functionality.
- Type: Negative Testing.
- Scenarios:
- Verifies that the system prevents login.
- Asserts the correct error message: "Sorry, this user has been locked out."
- Validates visual cues (Red input fields and error icons).
- Type: Functional/UI Bug Testing.
- Scenarios:
- Broken Image Verification: Detected by checking image source attributes in the Inventory.
- Type: Non-Functional / Performance Testing.
- Scenarios:
- Login Latency: Measures login time using
Stopwatch. - Asserts that login takes longer than the standard threshold to verify the system behavior.
- Login Latency: Measures login time using
- Type: JavaScript/Logic Error Testing.
- Scenarios:
- Checkout Failure: Verifies that this user cannot complete a purchase. The test specifically checks that clicking "Finish" fails to redirect to the confirmation page (due to a known site bug for this user).
This project uses an appsettings.json file to manage environment variables. Ensure this file exists in the root directory and is set to "Copy to Output Directory: Always".
{
"BrowserSettings": {
"UseCustomBinary": true,
"BinaryPath": "/Path/To/Your/Chrome/Or/Brave/Binary"
},
"Headless": false,
"BaseUrl": "https://www.saucedemo.com/",
"SauceSettings": {
"Password": "secret_sauce",
"Users": {
"Standard": "standard_user",
"LockedOut": "locked_out_user",
"Problem": "problem_user",
"Performance": "performance_glitch_user",
"Error": "error_user",
"Visual": "visual_user"
}
}
}SauceTesting/
├── Pages/ # Page Object Classes
│ ├── BasePage.cs # Common WebDriver methods
│ ├── LoginPage.cs # Auth interactions
│ ├── InventoryPage.cs # Catalog & Sorting
│ ├── ProductDetailsPage.cs # Individual Item View
│ ├── CartPage.cs # Cart Management
│ ├── CheckoutStepOnePage.cs # User Info Input
│ ├── CheckoutStepTwoPage.cs # Overview & Totals
│ └── CheckoutCompletePage.cs # Order Confirmation
│
├── Tests/ # NUnit Test Classes
│ ├── BaseTest.cs # Setup, Teardown, Reporting, Screenshots
│ ├── LoginTests.cs # Auth & Performance Tests
│ ├── InventoryTests.cs # Sorting & Broken Images
│ ├── ProductDetailsTest.cs # Product View Logic
│ ├── CartTests.cs # Add/Remove logic
│ ├── CheckoutTests.cs # E2E Purchase Flow
│ └── FooterTests.cs # External Link Verification
│
├── Enums/
│ └── SortOptions.cs # Sorting constants
│
├── appsettings.json # Configuration file
└── SauceTesting.sln # Solution file
After executing the tests, an HTML report is generated automatically using ExtentReports.
- Location:
SauceTesting/bin/Debug/net8.0/Reports/index.html - Content:
- Pass/Fail status for every test.
- Execution duration.
- Screenshots: If a test fails, a base64 screenshot of the browser state is embedded directly into the report.
- .NET SDK installed.
- Visual Studio or VS Code (with C# Dev Kit).
- Google Chrome installed.
Option 1: Command Line
dotnet testOption 2: Visual Studio / VS Code
- Open the Solution.
- Open Test Explorer.
- Click Run All Tests.