Web automation testing example using Selenium WebDriver with TypeScript and the Page Object Model.
The test suite targets the Project for Testing demo application.
📊 Example Report · 🚀 Test Report
- Node.js 24+
- npm
Clone the repository and install dependencies:
git clone https://github.com/imranwijaya/selenium-typescript-example.git
cd selenium-typescript-example
npm installCreate a local .env file based on .env.example:
Copy the example environment file:
cp .env.example .envConfigure the required environment variables:
BASE_URL="https://example.com"
BROWSER_NAME="chrome"
BROWSER_MODE="headless"
LOGIN_NAME="your-login-name"
LOGIN_EMAIL="your-email@example.com"
LOGIN_PASSWORD="your-password"
DB_HOST="127.0.0.1"
DB_NAME="your-database"
DB_USER="your-database-user"
DB_PASSWORD="your-database-password"
DB_PORT=3306The environment configuration is loaded from .env and validated with Zod
before Mocha starts.
Run the compiled JavaScript test suite:
npm run testRun the TypeScript development test suite:
npm run devRun TypeScript type checking:
npm run typecheckBuild the project:
npm run buildThe browser is configured through BROWSER_NAME.
Currently supported browsers:
- Chrome
- Firefox
Chrome is the currently validated browser configuration.
Mochawesome reports are generated under reports/. The reports can be viewed locally after test execution.
Selenium E2E tests run automatically whenever code is pushed to main.
The CI workflow:
- Checks out the repository.
- Runs the Selenium E2E suite on an Ubuntu GitHub-hosted runner.
- Sets up Node.js 24 and installs project dependencies with
npm ci. - Configures the test environment from GitHub Actions Variables and Secrets.
- Runs the E2E test suite using the configured browser.
- Publishes test results to the GitHub Actions job summary.
- Uploads the generated test reports as workflow artifacts.
- Publishes the reports to GitHub Pages for pushes to
main.
The following configuration is stored as GitHub Actions Variables:
BASE_URLBROWSER_NAMEBROWSER_MODELOGIN_NAMELOGIN_EMAILLOGIN_PASSWORD
The following database configuration is stored as GitHub Actions Secrets:
DB_HOSTDB_USERDB_PASSWORDDB_NAME
Local development continues to use .env.
GitHub Actions provides the environment variables through GitHub Variables and Secrets, keeping environment-specific configuration outside the repository.
The Selenium workflow can also be triggered by the Project for Testing Application CD workflow after a successful deployment.
The integration flow is:
Application CI
↓
Application CD
↓
Deploy application
↓
Health / readiness validation
↓
repository_dispatch
↓
Selenium E2E
↓
Validate deployed application
This allows Selenium E2E tests to validate the deployed application after the deployment pipeline has completed successfully.
Test reports from successful pushes to main are published to GitHub Pages.
The published reports provide accessible test evidence without requiring access to the GitHub Actions workflow.
Test execution provides multiple forms of evidence:
- GitHub Actions job summary
- Mochawesome HTML reports
- GitHub Actions workflow artifacts
- GitHub Pages published reports
The Selenium E2E suite has been validated locally and through GitHub Actions using Node.js 24 and the current Selenium WebDriver configuration.
For main branch pushes, the generated Mochawesome report is also published through GitHub Pages for browser-based test result review.
.
├── .github/
│ └── workflows/
│ └── selenium.yml
├── config/
├── lib/
├── pages/
├── repositories/
├── tests/
├── reports/
├── .env.example
├── .mocharc.js
├── .mocharc.dev.js
├── package.json
├── tsconfig.json
└── README.md
The project uses the Page Object Model to separate test scenarios from browser interaction logic.
BasePage— shared WebDriver functionalityPages— central Page Object facadepages/admin/— shared WebDriver functionality for authenticated admin
The project uses Selenium WebDriver for browser automation.
This project is licensed under the MIT License.