Automate and verify the below basic functionalities of the OrangeHRM app using Cypress.
- Login
- User/Candidate Creation
- Created User/Candidate details verification
- View and Verify the project time report
Framework structure:
Folder/FileName | Purpose |
---|---|
e2e\test | Includes all the test cases |
fixtures\env\demo | Includes json files to parameterize the tests (addUser.json and users.json) |
support | Contains re-usable Cypress.commands in command.js |
screenshots | Contains screenshots when test case fails |
mocha-awesome | Contains HTML reports generated |
cypress.config.js | Configuration file used by Cypress to customize its behavior and settings |
package.json | Contains scripts to run the test cases and github details |
.gitignore | Contains files/folders that have to be ignored for every git commit |
Instructions on how to run the tests are below
Pre-requisite:
Install the latest version of node.js from the link https://nodejs.org/en
Step 1: Clone the repository using VS Code editor as shown in screen shots below
git clone https://github.com/Zahid-Automate/OrangeCRMLive.git
Step 2: Install the required dependencies from terminal using below command
npm ci
Step 3: Use the below command from terminal to run login scenario
npx cypress run --headed --reporter mochawesome --spec ./cypress/e2e/test/loginTest.cy.js
Step 4: Use the below command from terminal to run User/Candidate Creation scenario
npx cypress run --headed --reporter mochawesome --spec cypress/e2e/test/addAndVerifyUser.cy.js",
Step 5: Use the below command from terminal to run User/Candidate details verification scenario
npx cypress run --headed --reporter mochawesome --spec ./cypress/e2e/test/loginTest.cy.js
Step 6: Use the below command from terminal to run View and Verify the project time report scenario
npx cypress run --headed --reporter mochawesome --spec ./cypress/e2e/test/loginTest.cy.js
To run all the scenarios use the below command in terminal
npx cypress run --headed --reporter mochawesome
Reports will be visible in mocha-awesome folder present at the root of the project
In case of failure : Screen shots will be visible in cypress/screenshots folder
Test Data Management : Test data is managed using json present in cypress/fixtures folder based on the environment demo/dev
addUser.json - This is used to add a user of admin or ess type with status enabled or disabled
user.json - This is used to get the credentials for various users based on the environment (demo/dev) for login and logout with the application
Custom commands (Present in cypress/support/command.js)
cy.loginAs: This command is used to login with the application
cy.openMenuItem: This command is used to open any menu item present on the left-hand side after login with the application
cy.AddUser: This command is used to add a new users
cy.verifyUserAndDelete: This command is used to verify that the user was added successfully and then delete the added user
================================
How to run Cypress in open mode
================================
Use the below command from terminal to run Cypress in open mode and follow the below steps
-
Click on E22 Testing
-
Select the browser of your choice and click on Start E2E Testing in Chrome
- From the Specs menu , click on any of the test cases present to be run