|
1 | | -# playwright-csharp-bdd-format-ui-automation-testing-suite |
2 | | -This repository contains automation test suite crafted in Behaviour Driven Development style using Playwright with C# and XUnit as the testing framework |
| 1 | +# BDD UI Automation Tests using Playwright in C\# with XUNIT |
| 2 | + |
| 3 | +## Overview |
| 4 | +This automation testing suite designed to perform end-to-end testing for a web application. Built with **Playwright** in **C#** and the **XUnit** testing framework, this project utilizes **Behavior-Driven Development (BDD)** with **Gherkin** syntax through the **SpecFlow** library in **DotNet**. The suite implements the **Page Object Model (POM)** design pattern, ensuring maintainability and scalability of the test codebase. |
| 5 | + |
| 6 | +The testing suite validates critical functionalities of a web platform, including: |
| 7 | +- **User Login**: Verifying successful authentication with valid credentials. |
| 8 | +- **Navigation Bar Validation**: Ensuring correct menu items are displayed for different user roles (Admin, Issuer, Private Investor). |
| 9 | +- **Signup Creation**: Testing the creation of user signups for various types. |
| 10 | + |
| 11 | +This project serves as a showcase of my expertise in designing and implementing scalable automation testing frameworks and is hosted on my public GitHub repository as part of my portfolio. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Project Structure |
| 16 | +The project is organized into logical directories and files, each with a specific role in the testing framework: |
| 17 | + |
| 18 | +``` |
| 19 | +UIAutomationTests/ |
| 20 | +├── Config/ # Configuration files |
| 21 | +├── Drivers/ # Playwright driver setup |
| 22 | +├── Features/ # Gherkin feature files defining test scenarios |
| 23 | +│ ├── Login.feature # Tests login functionality |
| 24 | +│ ├── NavbarValidation.feature# Tests navigation bar for different roles |
| 25 | +│ ├── SignupCreation.feature # Tests signup creation for organization types |
| 26 | +├── Hooks/ # SpecFlow hooks for setup and teardown |
| 27 | +│ ├── LoginHook.cs # Hook for login before specific scenarios |
| 28 | +├── Pages/ # Page Object Model classes for web pages |
| 29 | +│ ├── CreateUserPage.cs # Manages signup creation page interactions |
| 30 | +│ ├── IndexPage.cs # Manages index page interactions |
| 31 | +│ ├── LoginPage.cs # Manages login page interactions |
| 32 | +│ ├── Navbar.cs # Manages navigation bar interactions |
| 33 | +│ ├── OrganisationPage.cs # Manages organization-related pages |
| 34 | +├── StepDefinitions/ # Implementations of Gherkin steps |
| 35 | +│ ├── LoginStepDefinitions.cs # Steps for login feature |
| 36 | +│ ├── NavbarValidationStepDefinitions.cs # Steps for navbar validation |
| 37 | +│ ├── SignupCreationStepDefinitions.cs # Steps for signup creation |
| 38 | +├── appsettings.json # Configuration settings |
| 39 | +├── ImplicitUsings.cs # Implicit usings for the project |
| 40 | +└── UIAutomationTests.csproj # Project file |
| 41 | +``` |
| 42 | + |
| 43 | +### Key Components |
| 44 | +1. **Features/**: Gherkin `.feature` files written in BDD style written in Given, When, Then, And human readable style. |
| 45 | + - `Login.feature`: Tests login with valid credentials. |
| 46 | + - `NavbarValidation.feature`: Validates navigation bar items for Admin, Issuer, and Private Investor roles. |
| 47 | + - `SignupCreation.feature`: Tests signup creation for multiple organization types. |
| 48 | + |
| 49 | +2. **Hooks/**: SpecFlow hooks for scenario setup. |
| 50 | + - `LoginHook.cs`: Implements a `@LoginRequired` tag to handle login before applicable scenarios. |
| 51 | + |
| 52 | +3. **Pages/**: Implements the Page Object Model for maintainable test code. Each class containing UI locators of that page and reusable functions. |
| 53 | + - `CreateUserPage.cs`: Handles signup creation page interactions. |
| 54 | + - `LoginPage.cs`: Manages login page actions and verifications. |
| 55 | + - `Navbar.cs`: Validates navigation bar behavior across user roles. |
| 56 | + |
| 57 | +4. **StepDefinitions/**: C# implementations of defined scenarios in the feature files. |
| 58 | + - `LoginStepDefinitions.cs`: Defines login scenario steps. |
| 59 | + - `NavbarValidationStepDefinitions.cs`: Defines navbar validation steps. |
| 60 | + - `SignupCreationStepDefinitions.cs`: Defines signup creation steps. |
| 61 | + |
| 62 | +5. **Configuration**: Uses `appsettings.json` and user secrets for managing sensitive data like credentials and URLs. |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Features and Scenarios |
| 67 | + |
| 68 | +### 1. Login Feature |
| 69 | +**File**: `Login.feature` |
| 70 | +Tests the login functionality of the web platform. |
| 71 | + |
| 72 | +**Scenario**: Logging in with valid credentials |
| 73 | +``` |
| 74 | +Scenario: Logging in to platform with a valid username and password |
| 75 | + Given We navigate to the login page |
| 76 | + And We click on accept consent button |
| 77 | + And We enter username and password and click on Login button |
| 78 | + Then User is logged into dashboard |
| 79 | +``` |
| 80 | + |
| 81 | +### 2. Navbar Validation Feature |
| 82 | +**File**: `NavbarValidation.feature` |
| 83 | +Validates navigation bar items for different user roles. |
| 84 | + |
| 85 | +#### Scenario 1: Admin User Navbar Validation |
| 86 | +``` |
| 87 | +Scenario: Admin user login to the platform and verifies all the navbar items that he is authorized to see |
| 88 | + Given "[ADMIN_EMAIL_ADDRESS]@gmail.com" logs in to the platform |
| 89 | + When When the navbar appears |
| 90 | + And "Dashboard" is appearing in the navbar |
| 91 | + And "Deal analytics" is appearing in the navbar |
| 92 | + And "Companies" is appearing in the navbar |
| 93 | + And "Offers"is appearing in the navbar |
| 94 | + And "Investor profiles" is appearing in the navbar |
| 95 | + And "Meetings" is appearing in the navbar |
| 96 | +``` |
| 97 | + |
| 98 | +#### Scenario 2: Issuer User Navbar Validation |
| 99 | +``` |
| 100 | +Scenario: Issuer user login to the platform and verifies all the navbar items that he is authorized to see |
| 101 | + Given "[ISSUER_EMAIL_ADDRESS]@gmail.com" logs in to the platform |
| 102 | + When When the navbar appears |
| 103 | + And "Dashboard" is appearing in the navbar |
| 104 | + And "My company" is appearing in the navbar |
| 105 | + And "Merger and acquisitions" is appearing in the navbar |
| 106 | + And "Matchmaking" is appearing in the navbar |
| 107 | + And "Data rooms" is appearing in the navbar |
| 108 | + And "Document access" is appearing in the navbar |
| 109 | + And "Meetings" is appearing in the navbar |
| 110 | + And "Auction management" is appearing in the navbar |
| 111 | + And "Offers" is appearing in the sub menu of "Auction management" in the navbar |
| 112 | + And "Flags" is appearing in the sub menu of "Auction management" in the navbar |
| 113 | + And "Tranches" is appearing in the sub menu of "Auction management" in the navbar |
| 114 | + And "Interest" is appearing in the navbar |
| 115 | + And "Secondary" is appearing in the sub menu of "Auction management" in the navbar |
| 116 | + And "Private" is appearing in the sub menu of "Auction management" in the navbar |
| 117 | + And "Forms" is appearing in the navbar |
| 118 | + And "Questionnaires" is appearing in the sub menu of "Forms" in the navbar |
| 119 | + And "Forms" is appearing in the sub menu of "Forms" in the navbar |
| 120 | + And "User management" is appearing in the navbar |
| 121 | + And "Referrals" is appearing in the sub menu of "User management" in the navbar |
| 122 | + And "Refer an investor" is appearing in the sub menu of "User management" in the navbar |
| 123 | +``` |
| 124 | + |
| 125 | +#### Scenario 3: Private Investor User Navbar Validation |
| 126 | +``` |
| 127 | +Scenario: Private investor user login to the platform and verifies all the navbar items that he is authorized to see |
| 128 | + Given "[INVESTOR_EMAIL_ADDRESS]@gmail.com" logs in to the platform |
| 129 | + When When the navbar appears |
| 130 | + And "Home" is appearing in the navbar |
| 131 | + And "Companies" is appearing in the navbar |
| 132 | + And "Companies" is appearing in the sub menu of "Companies" in the navbar |
| 133 | + And "Offers" is appearing in the sub menu of "Companies" in the navbar |
| 134 | + And "Meetings" is appearing in the sub menu of "Companies" in the navbar |
| 135 | + And "Investors" is appearing in the navbar |
| 136 | + And "My invitations" is appearing in the sub menu of "Investors" in the navbar |
| 137 | + And "Referrals" is appearing in the sub menu of "Investors" in the navbar |
| 138 | + And "Refer an investor" is appearing in the sub menu of "Investors" in the navbar |
| 139 | +``` |
| 140 | + |
| 141 | +### 3. Signup Creation Feature |
| 142 | +**File**: `SignupCreation.feature` |
| 143 | +Tests signup creation for various organization types. |
| 144 | + |
| 145 | +**Scenario**: Creating signups for different organization types |
| 146 | +``` |
| 147 | +Scenario: Creating signups for the organisations of type Admin, Advisor, Advocate, Issuer, Institutional investor and Private investor |
| 148 | + Given User navigates to the signup management page |
| 149 | + When User clicks on Create user button and then enters organisation name and type and click on save button |
| 150 | + | organisationType | Role | FirstName | LastName | |
| 151 | + | Advisor | Advisor corporate | Adv | isor | |
| 152 | + | Advocate | Advocate | Advo | cate | |
| 153 | + | Issuer | Issuer | Iss | user | |
| 154 | + | Admin | Administrator | Adm | in | |
| 155 | + | Institutional Investor | Bidder | Institutional| investor | |
| 156 | + | Private Investor | Bidder | Private | investor | |
| 157 | + Then The signup is created successfully |
| 158 | +``` |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## Technologies Used |
| 163 | +- **Playwright**: Browser automation for end-to-end testing. |
| 164 | +- **C#**: Core programming language for test scripts. |
| 165 | +- **XUnit**: Framework for running and asserting tests. |
| 166 | +- **SpecFlow**: Enables BDD with Gherkin syntax. |
| 167 | +- **Page Object Model (POM)**: Design pattern for maintainable test code. |
| 168 | +- **Microsoft.Extensions.Configuration**: Manages sensitive data via user secrets. |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## Key Features and Highlights |
| 173 | +- **BDD with Gherkin**: Human-readable test scenarios for technical and non-technical stakeholders. |
| 174 | +- **Page Object Model**: Organized, reusable code for web interactions. |
| 175 | +- **Role-Based Testing**: Validates UI behavior for multiple user roles. |
| 176 | +- **SpecFlow Hooks**: Automates setup tasks like login with `@LoginRequired`. |
| 177 | +- **Secure Configuration**: Uses user secrets for sensitive data management. |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## Contact |
| 182 | +For questions or feedback, reach out to me: |
| 183 | +- **GitHub**: [EhtashamAhmed](https://github.com/EhtashamAhmed) |
| 184 | +- **LinkedIn**: [Ehtasham Ahmad](https://www.linkedin.com/in/ehtasham-ahmad-b76807151/) |
| 185 | +- **Email**: [ehtashamahmedea@gmail.com](mailto:[ehtashamahmedea@gmail.com]) |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +This project highlights my skills in automation testing and framework design. I hope you find it a valuable addition to my portfolio! |
0 commit comments