Skip to content

aserna77/Dualboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demoblaze Product Store - Automated UI Testing Framework (C# .NET 8, NUnit, Selenium)

Overview

This project automates web UI testing for the Demoblaze Product Store website using the following technologies:

  • C# (.NET 8)
  • Selenium WebDriver
  • NUnit test framework
  • WebDriverManager for automatic browser driver setup
  • Page Object Model (POM) design pattern
  • Configurable browser options via appsettings.json

The goal is to provide a clean, maintainable, and beginner-friendly automation framework.


1. Prerequisites

Before running the tests, make sure you have the following installed on your computer:

  1. Windows 10/11 or macOS
  2. Visual Studio 2022 (Community, Professional, or Enterprise)
  3. .NET 8 SDK Download from: https://dotnet.microsoft.com/download
  4. Google Chrome (latest version)
  5. Internet connection to restore NuGet packages automatically

💡 No need to manually download ChromeDriver — it’s managed automatically by WebDriverManager.


2. How to Open and Run the Project

Follow these steps carefully — even if you have never used Visual Studio before.

  1. Unzip the project

    • Right-click on the ZIP file and select Extract All…
    • Save the extracted folder somewhere easy to find, e.g. C:\Projects\DemoblazeProductStore
  2. Open the project in Visual Studio

    • Start Visual Studio 2022.
    • Click Open a project or solution.
    • Browse to the extracted folder and open the file DemoblazeProductStore.csproj.
  3. Restore dependencies

    • When the project loads, Visual Studio automatically restores NuGet packages.

    • Wait until the process finishes (check the progress bar at the bottom).

    • If it doesn’t happen automatically:

      • Go to Tools → NuGet Package Manager → Package Manager Console

      • Run this command:

        dotnet restore
        
  4. Build the solution

    • In the top menu, click Build → Build Solution or press Ctrl + Shift + B.
    • Wait for the build to complete successfully (you should see “Build succeeded”).
  5. Run the tests

    • Open the Test Explorer from Test → Test Explorer.
    • You’ll see a list of available tests (for example, ValidLoginTest, InvalidLoginTest, etc.).
    • Right-click a test or select Run All Tests.
    • Chrome will open automatically, run the test, and close when finished.

3. Changing Browser Settings

You can modify how the browser behaves by editing the Config/appsettings.json file:

{
  "browser": "chrome",
  "headless": false
}
  • "browser" — choose chrome or another browser if implemented.
  • "headless": true — runs tests without showing the browser window.

4. Project Structure

Folder Description
Drivers/ Contains DriverFactory for initializing and closing the browser.
Pages/ Contains all Page Object classes representing pages of the website.
Tests/ Contains NUnit test classes that perform actions and verifications.
Config/ Contains configuration files like appsettings.json.
Utils/ Contains helper classes (if any).

5. Typical Execution Flow

  1. The test starts and calls the DriverFactory to initialize Chrome using WebDriverManager.
  2. The browser opens https://www.demoblaze.com.
  3. Page Object classes interact with elements (login, add products, etc.).
  4. NUnit validates the expected results (assertions).
  5. The browser closes after each test (handled automatically by hooks or teardown methods).

6. Troubleshooting

Problem Possible Cause / Solution
Chrome does not open Make sure Google Chrome is installed and up to date.
Build fails Ensure .NET 8 SDK is installed correctly.
Tests not visible in Test Explorer Go to Test → Test Explorer → Run All Tests or rebuild the solution.
Browser stays open after tests Verify that Driver.Quit() is called in your teardown method.

7. How to Add New Tests

  1. Create a new class under the Tests folder (e.g., SignupTests.cs).
  2. Decorate the class with [TestFixture].
  3. Add test methods marked with [Test].
  4. Use Page Object classes to perform actions and assertions.
  5. Build and run the new test — it will automatically appear in Test Explorer.

Example:

[Test]
public void ExampleTest()
{
    var driver = DriverFactory.Driver;
    driver.Navigate().GoToUrl("https://www.demoblaze.com");
    Assert.IsTrue(driver.Title.Contains("STORE"));
}

8. Summary

After following this guide, you will:

  • Open and run automated UI tests with Selenium and NUnit.
  • Understand how Page Object Model organizes code.
  • Adjust settings in appsettings.json to change browsers or run headless.

The framework is simple, scalable, and ready for further extensions (e.g., reporting, logging, or CI/CD integration).

Enjoy testing!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages