A Playwright-based automated UI test suite for the Rahul Shetty Academy demo e-commerce web application. Built with C#, .NET 10, and xUnit, this project uses a Page Object Model architecture to centralize page actions, secure credential handling, and trace-based debugging.
PlaywrightTests.csproj— project definition and dependency listUI_Tests/— test classes organized by TC numberPages/— page object implementations and tracing helpersData/— JSON-driven test input dataUtilities/— helper utilities such as credentials management.github/workflows/playwright-tests.yml— GitHub Actions test pipelineCREDENTIALS_SETUP.md— secure credential setup guide
- .NET 10 SDK
- Playwright browser dependencies
- Windows PowerShell or compatible shell
-
Clone the repository:
git clone <repository-url> cd xUnitPlaywrightTests
-
Restore dependencies:
dotnet restore
-
Install Playwright browsers:
dotnet tool install --global Microsoft.Playwright.CLI playwright install
-
Configure credentials (see Configuration).
Run all tests:
dotnet test PlaywrightTests.csprojRun a single test by fully qualified name:
dotnet test --filter FullyQualifiedName~TC0014_Verify_ContinueShopping_FunctionalityPlaywright traces are recorded for each test and saved to playwright-traces/.
Use the Playwright trace viewer to inspect a trace:
playwright show-trace playwright-traces/TC0014_Verify_ContinueShopping_Functionality.VerifyContinueShoppingFunctionality.zip- Review trace files in
playwright-traces/ - Consult the page object methods in
Pages/HomePage.csandPages/CartPage.cs - Check the JSON data values in
Data/HomePage.json
- 14 automated test cases covering login, search, filtering, cart behavior, checkout, and continue shopping flows
- Page Object Model for reusable page actions in
Pages/ - Secure credential management using user secrets or environment variables
- Trace recording with screenshots, snapshots, and sources
- Centralized test input in
Data/HomePage.json - GitHub Actions integration for CI/CD validation
Credentials are loaded from Utilities/CredentialsHelper.cs. Supported sources:
-
User Secrets (recommended for local development):
dotnet user-secrets set "Credentials:Username" "<username>" dotnet user-secrets set "Credentials:Password" "<password>"
-
Environment Variables (for CI/CD):
$env:TEST_USERNAME = "<username>" $env:TEST_PASSWORD = "<password>"
For detailed instructions, see CREDENTIALS_SETUP.md.
On GitHub Actions, set repository secrets named
TEST_USERNAMEandTEST_PASSWORDso CI can run login tests without storing credentials in source control.
Data values are defined in Data/HomePage.json.
Update these fields to change the test inputs:
{
"URL": "https://rahulshettyacademy.com/client/#/auth/login",
"expectedURL": "https://rahulshettyacademy.com/client/#/dashboard/dash",
"expectedTitle": "Let's Shop",
"searchTerm": "ADIDAS",
"minPrice": "50000",
"maxPrice": "60000",
"category1": "fashion",
"category2": "electronics",
"category3": "household",
"product": "ZARA COAT 3"
}The repository includes a GitHub Actions workflow at .github/workflows/playwright-tests.yml.
The workflow:
- checks out the code
- sets up .NET 10
- restores dependencies
- builds the project
- installs Playwright browsers using
pwsh bin/Release/net10.0/playwright.ps1 install - runs tests and generates a TRX report
- uploads test results as an artifact
- publishes results using the EnricoMi action
To add a new test:
- Create a new folder under
UI_Tests/TC00xx/. - Add a
_TestObject.csfile for JSON data deserialization. - Add a
_Verify_<feature>.csfile for test logic. - Use existing page objects from
Pages/. - Update
Data/HomePage.jsonwith new test values. - Follow naming conventions:
TC00xx_Verify_<Feature>.cs.
- Do not commit credentials, secrets, or
.envfiles. - Use secure storage for credentials and environment configuration.
Pages/HomePage.csandPages/CartPage.cscontain the main reusable UI actions.- Trace artifacts are stored in
playwright-traces/and can be opened with Playwright Inspector.