A robust, scalable Selenium test automation framework built with C# / .NET 9 implementing the Page Object Design Pattern (POM). This framework automates the Guru99 Bank Demo Application and serves as a production-ready template for web UI test automation.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SeleniumPOM Solution β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β TestCase/ βββββΆβ TestContext/ βββββΆβ Pages/ β β
β β β β β β β β
β β LoginTest β β TestClass β β ββββββββββ βββββββββββ β β
β β HomeTest β β Context β β βActions/β βLocators/β β β
β β NewCustomer β β β β β β β β β β
β β EditCustomerβ β β’ ExtentRpt β β βLoginPg β βLoginLoc β β β
β β DeleteCust β β β’ SetUp/ β β βHomePg β βHomeLoc β β β
β β NewAccount β β TearDown β β βNewCust β βNewCustL β β β
β β EditAccount β β β β βEditCustβ βEditCustLβ β β
β β DeleteAcct β ββββββββββββββββ β βDeleteCuβ βDelCustL β β β
β β Deposit β β βNewAcct β βNewAcctL β β β
β β Withdrawal β β βEditAcctβ βEditAcctLβ β β
β β FundTransferβ β βDelAcct β βDelAcctL β β β
β β BalanceEnq β β βDeposit β βDepositL β β β
β β MiniStmt β β βWithdrawβ βWithdrawLβ β β
β β CustomStmt β β βFundTrfrβ βFundTrfrLβ β β
β βββββββββββββββ β βBalEnq β βBalEnqL β β β
β β βMiniStmtβ βMiniStmtLβ β β
β β βCustStmtβ βCustStmtLβ β β
β β ββββββββββ βββββββββββ β β
β β β β
β β ββββββββββββββββββββββ β β
β β β BasePage/ β β β
β β β Page.cs β β β
β β β β’ WebDriver Init β β β
β β β β’ Browser Setup β β β
β β β β’ Session Mgmt β β β
β β ββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββββββββββ β
β β Interfaces/ β β Utilities/ β β Config/ β β Setting/ β β
β β β β β β β β β β
β β ILoginPage β β Utils.cs β β AppConfig β β AppConfig β β
β β IHomePage β β ExtentRpt β β Reader.cs β β Keys.cs β β
β β INewCustPg β β Helper.cs β β Constants.cs β β ObjectRepo β β
β β IEditCustPg β β Log4Net β β appsettings β β sitory.cs β β
β β IDeleteCust β β Helper.cs β β .json β β β β
β β INewAcctPg β β MailUtil.cs β β extent- β ββββββββββββββ β
β β IEditAcctPg β β β β config.xml β β
β β IDeleteAcct β ββββββββββββββββ ββββββββββββββββ β
β β IDepositPg β β
β β IWithdrawal β ββββββββββββββββ ββββββββββββββββ ββββββββββββββ β
β β IFundTransfr β β CustomExcep/ β β TestData/ β βTestReports/β β
β β IBalanceEnq β β β β β β β β
β β IMiniStmt β β NoSuitable β β Guru99Bank β β extent β β
β β ICustStmt β β DriverFound β β .xlsx β β .html β β
β β IConfig β β .cs β β β β β β
β β IUtil β ββββββββββββββββ ββββββββββββββββ ββββββββββββββ β
β ββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββββββββ
β MSTest ββββββΆβ TestClass ββββββΆβ Page.cs ββββββΆβ WebDriverβ
β Runner β β Context β β (BasePage) β β Manager β
ββββββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββ¬ββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββ
β Test Case β β Action Page β β Chrome / β
β (e.g. ββββββΆβ (e.g. ββββββΆβ Firefox β
β LoginTest) β β LoginPage) β β Browser β
ββββββββββββββββ ββββββββ¬ββββββββ ββββββββββββ
β
βΌ
ββββββββββββββββ
β Locator β
β (e.g. β
β LoginPage β
β Locators) β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β Utils.cs β
β β’ Click β
β β’ SendKeys β
β β’ Wait β
β β’ JS Exec β
ββββββββββββββββ
| Component | Library | Version |
|---|---|---|
| Runtime | .NET | 9.0 |
| Browser Automation | Selenium WebDriver | 4.29.0 |
| Browser Support | Selenium Support | 4.29.0 |
| Page Objects | DotNetSeleniumExtras.PageObjects.Core | 4.14.1 |
| Wait Helpers | DotNetSeleniumExtras.WaitHelpers | 3.11.0 |
| Driver Management | WebDriverManager | 2.17.5 |
| Test Framework | MSTest (TestAdapter + Framework) | 3.7.3 |
| Test SDK | Microsoft.NET.Test.Sdk | 17.12.0 |
| Reporting | ExtentReports | 5.0.4 |
| Logging | log4net | 3.0.4 |
| Configuration | Microsoft.Extensions.Configuration | 9.0.4 |
| JSON Handling | Newtonsoft.Json | 13.0.3 |
| Database | MongoDB.Driver | 3.3.0 |
SeleniumPOM/
βββ appsettings.json # Application configuration (browser, URL, credentials)
βββ SeleniumPOM.csproj # SDK-style project file targeting .NET 9
β
βββ Config/ # Configuration layer
β βββ AppConfigReader.cs # Reads settings from appsettings.json
β βββ Constants.cs # Application-wide constants (email, report paths)
β βββ extent-config.xml # ExtentReports XML configuration
β
βββ CustomException/ # Custom exception classes
β βββ NoSuitableDriverFound.cs # Thrown when browser config is invalid
β
βββ Interfaces/ # Interface contracts for all pages
β βββ IConfig.cs # Configuration reader interface
β βββ IUtil.cs # Utility operations interface
β βββ ILoginPage.cs # Login page operations
β βββ IHomePage.cs # Home page navigation
β βββ INewCostumerPage.cs # New customer form operations
β βββ IEditCostumerPage.cs # Edit customer operations
β βββ IDeleteCustomerPage.cs # Delete customer operations
β βββ INewAccountPage.cs # New account operations
β βββ IEditAccountPage.cs # Edit account operations
β βββ IDeleteAccountPage.cs # Delete account operations
β βββ IDepositPage.cs # Deposit operations
β βββ IWithdrawalPage.cs # Withdrawal operations
β βββ IFundTransferPage.cs # Fund transfer operations
β βββ IBalanceEnquiryPage.cs # Balance enquiry operations
β βββ IMiniStatementPage.cs # Mini statement operations
β βββ ICustomisedStatementPage.cs # Customised statement operations
β
βββ Pages/ # Page Object Model implementation
β βββ BasePage/
β β βββ Page.cs # Base class: WebDriver init, browser setup, teardown
β βββ Locators/ # Element locators using @FindsBy annotations
β β βββ LoginPageLocators.cs
β β βββ HomePageLocator.cs
β β βββ NewCustomerLocators.cs
β β βββ EditCostumerLocator.cs
β β βββ DeleteCustomerLocator.cs
β β βββ NewAccountLocator.cs
β β βββ EditAccountLocator.cs
β β βββ DeleteAccountLocator.cs
β β βββ DepositLocator.cs
β β βββ WithdrawalLocator.cs
β β βββ FundTrasferLocator.cs
β β βββ BalanceEnquiryLocator.cs
β β βββ MiniStatementLocator.cs
β β βββ CustomisedStatementLocator.cs
β βββ Actions/ # Page action methods (business logic)
β βββ LoginPage.cs
β βββ HomePage.cs
β βββ NewCustomerPage.cs
β βββ EditCustomerPage.cs
β βββ DeleteCustomerPage.cs
β βββ NewAccountPage.cs
β βββ EditAccountPage.cs
β βββ DeleteAccountPage.cs
β βββ DepositPage.cs
β βββ WithdrawalPage.cs
β βββ FundTrasferPage.cs
β βββ BalanceEnquiryPage.cs
β βββ MiniStatementPage.cs
β βββ CustomisedStatementPage.cs
β
βββ Setting/ # Application settings
β βββ AppConfigKeys.cs # Configuration key constants
β βββ ObjectRepsitory.cs # Static config object holder
β
βββ TestCase/ # MSTest test classes
β βββ LoginTest.cs
β βββ HomeTest.cs
β βββ NewCustomerTest.cs
β βββ EditCustomerTest.cs
β βββ DeleteCustomerTest.cs
β βββ NewAccountTest.cs
β βββ EditAccountTest.cs
β βββ DeleteAccountTest.cs
β βββ DepositTest.cs
β βββ WithdrawalTest.cs
β βββ FundTransferTest.cs
β βββ BalanceEnquiryTest.cs
β βββ MiniStatementTest.cs
β βββ CustomisedStatementTest.cs
β βββ UnitTest1.cs
β
βββ TestContextClass/ # Test lifecycle management
β βββ TestClassContext.cs # Assembly init/cleanup, ExtentReports setup
β
βββ Utilities/ # Helper utilities
β βββ Utils.cs # WebElement interactions (click, type, wait, JS)
β βββ ExtentReportsHelper.cs # ExtentReports 5.x Spark reporter wrapper
β βββ Log4NetHelper.cs # log4net programmatic configuration
β βββ MailUtil.cs # Email report sender via SMTP
β
βββ TestData/ # Test data files
β βββ Guru99Bank.xlsx # Excel test data
β
βββ TestReports/ # Generated HTML test reports
β βββ extent.html
β
βββ Logs/ # Generated log files
βββ FileLogger.log
βββ RollingFileLogger.log
Each web page is represented by two classes:
- Locator class β Defines element locators using
[FindsBy]attributes withPageFactory - Action class β Implements business logic methods that interact with elements
Every page has a corresponding interface (e.g., ILoginPage), enabling:
- Loose coupling between test cases and page implementations
- Easy mocking for unit testing
- Clear API contracts
Page.cs serves as the base class providing:
- WebDriver initialization with
WebDriverManager(auto-downloads correct driver) - Browser configuration (Chrome/Firefox)
- Session management (cookies, timeouts, window maximization)
Utils.cs wraps common Selenium operations with built-in explicit waits:
ClickOnElement()β Wait + ClickEnterTextIntoElement()β Wait + SendKeysGetElementText()β Wait + Get TextSelectByVisibleText()β Dropdown selectionJSExecutor()/JSExecutorClick()β JavaScript executionGetAlertTextAndAccept()β Alert handling
Test Layer Page Layer Utility Layer Driver Layer
ββββββββββ ββββββββββ βββββββββββββ ββββββββββββ
β β β β
β Login(user,pwd) β β β
ββββββββββββββββββββΆβ β β
β β EnterText(element) β β
β ββββββββββββββββββββββββΆβ β
β β β FindElement() β
β β ββββββββββββββββββββββΆβ
β β β SendKeys() β
β β ββββββββββββββββββββββΆβ
β β βββββββββββββββββββββββ
β βββββββββββββββββββββββββ β
β β Click(loginBtn) β β
β ββββββββββββββββββββββββΆβ β
β β β Click() β
β β ββββββββββββββββββββββΆβ
β β βββββββββββββββββββββββ
β βββββββββββββββββββββββββ β
β return HomePage β β β
βββββββββββββββββββββ β β
β β β β
- .NET 9 SDK installed
- Chrome or Firefox browser installed
# Clone the repository
git clone https://github.com/lkumarra/Selenium.NET.git
cd Selenium.NET
# Restore NuGet packages
dotnet restore
# Build the project
dotnet build
# Run all tests
dotnet test
# Run tests with detailed output
dotnet test --logger "console;verbosity=detailed"
# Run a specific test
dotnet test --filter "VerifyLogin"- Open
SeleniumPOM.sln - Build the solution (
Ctrl+Shift+B) - Open Test Explorer (
Ctrl+E, T) - Run individual tests or all tests
Application settings are in SeleniumPOM/appsettings.json:
{
"AppSettings": {
"Browser": "Chrome",
"UserName": "your_username",
"Password": "your_password",
"Url": "http://www.demo.guru99.com/V4/index.php"
}
}| Key | Description | Values |
|---|---|---|
Browser |
Browser to use for testing | Chrome, Firefox |
UserName |
Login username | Any valid username |
Password |
Login password | Corresponding password |
Url |
Application URL | Target web application URL |
- Reports are auto-generated at
TestReports/extent.html - Uses ExtentSparkReporter (ExtentReports 5.x)
- Includes system info, test status (Pass/Fail/Skip), and screenshots
- Console Appender β Real-time output during test execution
- File Appender β
Logs/FileLogger.log - Rolling File Appender β
Logs/RollingFileLogger.log(max 15 backups)
To enable email reports after test execution:
- Fill in email details in
Config/Constants.cs - Uncomment
MailUtil.SendAttachedReport()inTestContextClass/TestClassContext.cs
| Aspect | Before (v1) | After (v2) |
|---|---|---|
| Framework | .NET Framework 4.7.2 | .NET 9.0 |
| Project Format | Legacy .csproj + packages.config |
SDK-style .csproj |
| Selenium | 3.141.0 | 4.29.0 |
| PageFactory | OpenQA.Selenium.Support.PageObjects |
DotNetSeleniumExtras.PageObjects.Core |
| ExpectedConditions | OpenQA.Selenium.Support.UI |
SeleniumExtras.WaitHelpers |
| Configuration | App.config + ConfigurationManager |
appsettings.json + IConfiguration |
| Reporting | ExtentReports 3.x (ExtentHtmlReporter) |
ExtentReports 5.x (ExtentSparkReporter) |
| Test Framework | MSTest 2.1.1 | MSTest 3.7.3 |
| Driver Management | Manual driver binaries | WebDriverManager 2.17.5 (auto-download) |
This project is open source. See the license file for details.