This is a sample project that uses WebdriverIO and TypeScript. It includes examples of the PageObject pattern and some practical examples for using WebdriverIO for cross browser and parallel run. testing inside container, report portal integration.
Clone Repository
git clone https://github.com/sadabnepal/webdriverio-ts-mocha.git
cd webdriverio-ts-mochaInstall packages:
npm installRun tests:
npm run test [ test in chrome ]
npm run test:edge [ test in edge ]
npm run cross:browser [ test in chrome and edge ]Docker Run:
npm run docker:start [ start the docker container ]
npm run docker:stop [ stop the docker container ]
npm run test:docker [ test in docker container ]
# TODO: arm yml not found
npm run docker:start:arm [ start the docker container for mac m1 chip ]
npm run docker:stop:arm [ stop the docker container for mac m1 chip ]open http://localhost:4444/ to check if server is running
Generate report with historical data:
npm run move
npm run reportGenerate offline html report:
npm run report:htmlCleanup Report folder
npm run cleanup- Follow Browser Stack Integration Getting Started document
- Note down
BROWSERSTACK_USERNAMEandBROWSERSTACK_ACCESS_KEYfrom profile section - Paste value in .env for above copied content. Refer
.env.examplefile - Run
npm run test:bscommand to execute test in browser stack
- Setup: follow https://reportportal.io/installation
- Login: Open http://localhost:8080/ and login with time user
superadminand passworderebus - Generate API key:
- Click on bottom left of logged in user --> click on
Profile - Click on
API KEYS-->Generate API Key--> copy the generated key - Create
.envfile in root project folder. Refer.env.examplefile - Paste your API key into
.envfile asREPORT_PORTAL_KEY=<your api key>
- Click on bottom left of logged in user --> click on
- Enter
REPORT_PORTAL_PROJECT=<project_assignment>into.env. Value can be found onPROJECT ASSIGNMENTtab of user profile - Other details are updated in
tests/config/wdio.reportPortal.tsfile - add
REPORT_PORTAL_SWITCH=ONto push results to report portal
- Custom types for web elements
- Parallel execution and Cross browser testing
- Docker for testing against/using containerization
- Github actions CI/CD integration
- Report portal integration
- BrowserStack Integration
- dotenv to store secrets locally
- eslint linting tools integrated
- husky git hooks for pre-commit checks (eslint)
├───.github
├───.husky
├───.vscode
├───images
├───tests
| ├───config
| ├───docker
| ├───pages
| ├───resources
| ├───specs
| ├───static
| └───types
├───.env
├───.env.example
├───.eslintrc.js
├───.gitignore
├───docker-compose.yml
├───package-lock.json
├───package.json
├───README.md
└───tsconfig.json