An example project demonstrating automated UI tests with Node.js and JavaScript using TestCafe with Page Object Design Framework.
We are using https://www.opencart.com/ as the Application Under Test.
- URL : https://www.opencart.com/
- OS : macOS
- IDE : Visual Studio Code
Install the dependencies and devDependencies to run the test.
- Clone or Download this repo on your local machine
- Navigate to project's directory on terminal and run the following commands:
npm install
Run on Terminal
npm run clean
Run the following command on Terminal to execute tests in Chrome Headless mode
npm run test:chrome:headless
Run the following command on Terminal to execute tests on Chrome, Firefox and Safari
npm run test:chrome
npm run test:firefox
npm run test:safari
Run the following command on Terminal to execute tests in parallel with Chrome and Firefox
npm run test:parallel
Top - Level Directory Layout
├── pageobjects # Selectors CSS identifier for elements to test
│ ├── data .js # Test Data
│ ├── locators .js # Selectors
│
│
├── pages # Generic functionality for tests
│ |
│ ├── basePage.js # Base page testing functionality
│ ├── accountPage.js # Account details page testing functionality
│ ├── marketPlacePage.js # Market Place page testing functionality
│
│
├── tests # Test suite
│ ├── downloadFreeProduct.test.js # Automated Test Script
│ ├── searchBox.test.js # Automated Test Script
│ ├── sortByFeature.test.js # Automated Test Script
│
├── prettierrc # Code Formatting
│
├── testcaferc # TestCafe config file for screenshots on failed tests
│
├── allure-report # Allure Test Report
│
└─── screenshots # Screenshots captured for failed tests
Run the following command on Terminal
npm run clean
npm run test:chrome
npm run allure-report
Run on firefox headless in Docker container
docker build -t testcafe:v1 .
docker run -it testcafe:v1