cypress_task 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/cyemial.yaml +98 -0
- package/Daily_Tracker.xlsx +0 -0
- package/Mannual_testcases.xlsx +0 -0
- package/clean_mochawesome.js +26 -0
- package/cleanupOutput.js +16 -0
- package/cleanupReports.js +15 -0
- package/cypress/e2e/Cart_Testcases/07_verify_Adding_single_item_to_cart.cy.js +40 -0
- package/cypress/e2e/Cart_Testcases/08_verify_removing_item_from_the_cart.cy.js +55 -0
- package/cypress/e2e/Cart_Testcases/09_verify_updating_of_cart_after_adding_multiple_item.cy.js +75 -0
- package/cypress/e2e/Checkout_Testcases/04_verify_complete_successful_purchase_of_single_item.cy.js +83 -0
- package/cypress/e2e/Checkout_Testcases/05_verify_checkout_with_missing_firstname_fails.cy.js +78 -0
- package/cypress/e2e/Checkout_Testcases/06_verify_user_can_cancel_checkout_and redirected_to_cart.cy.js +79 -0
- package/cypress/e2e/Login_Testcases/01_Verify_Valid_Login.cy.js +30 -0
- package/cypress/e2e/Login_Testcases/02_Verify_Invalid_Login_by_wrong_password.cy.js +29 -0
- package/cypress/e2e/Login_Testcases/03_Verify_Lockout_user_failed_login.cy.js +30 -0
- package/cypress/e2e/Regression_Suit/10_Verify_successful_purchase_multiple_items.cy.js +98 -0
- package/cypress/e2e/Regression_Suit/11_testfail.cy.js +98 -0
- package/cypress/e2e/Smoke_Suit/SMK001_Verify user can log in with valid credentials.cy.js +32 -0
- package/cypress/e2e/Smoke_Suit/SMK002_Verify product list loads after login.cy.js +34 -0
- package/cypress/e2e/Smoke_Suit/SMK003_Verify user can add a product to cart.cy.js +49 -0
- package/cypress/failed-specs.json +3 -0
- package/cypress/fixtures/Cart/01_Adding_product_to_cart.json +6 -0
- package/cypress/fixtures/Cart/02_Removing_product_from_cart.json +6 -0
- package/cypress/fixtures/Cart/03_Updating_of_cart_icon.json +7 -0
- package/cypress/fixtures/Checkout/01_purchase_of_single_product.json +10 -0
- package/cypress/fixtures/Checkout/02_missing_info_fail_purchase.json +8 -0
- package/cypress/fixtures/Checkout/03_cancel_purcahse_redirect_to_cart.json +9 -0
- package/cypress/fixtures/Login_Data/01_Valid_login.json +5 -0
- package/cypress/fixtures/Login_Data/02_Invalid_Login.json +6 -0
- package/cypress/fixtures/Login_Data/03_Lockout_user.json +6 -0
- package/cypress/fixtures/regression_data/01_regression_data.json +12 -0
- package/cypress/fixtures/smoke_test_data/SMK001_Verify user can log in with valid credentials.json +5 -0
- package/cypress/fixtures/smoke_test_data/SMK002_Verify product list loads after login.json +6 -0
- package/cypress/fixtures/smoke_test_data/SMK003_Verify user can add a product to cart.json +6 -0
- package/cypress/results/fail_2025-12-19T160847+0530-11_testfail.json +110 -0
- package/cypress/results/fail_2025-12-19T160936+0530-11_testfail.json +110 -0
- package/cypress/results/pass_2025-12-19T160750+0530-04_verify_complete_successful_purchase_of_single_item.json +106 -0
- package/cypress/results/pass_2025-12-19T160756+0530-05_verify_checkout_with_missing_firstname_fails.json +106 -0
- package/cypress/results/pass_2025-12-19T160802+0530-06_verify_user_can_cancel_checkout_and redirected_to_cart.json +106 -0
- package/cypress/results/pass_2025-12-19T160806+0530-07_verify_Adding_single_item_to_cart.json +106 -0
- package/cypress/results/pass_2025-12-19T160809+0530-08_verify_removing_item_from_the_cart.json +106 -0
- package/cypress/results/pass_2025-12-19T160814+0530-09_verify_updating_of_cart_after_adding_multiple_item.json +106 -0
- package/cypress/results/pass_2025-12-19T160822+0530-10_Verify_successful_purchase_multiple_items.json +106 -0
- package/cypress/results/pass_2025-12-19T160850+0530-SMK001_Verify user can log in with valid credentials.json +106 -0
- package/cypress/results/pass_2025-12-19T160854+0530-SMK002_Verify product list loads after login.json +106 -0
- package/cypress/results/pass_2025-12-19T160857+0530-SMK003_Verify user can add a product to cart.json +106 -0
- package/cypress/results/pass_2025-12-19T160900+0530-01_Verify_Valid_Login.json +106 -0
- package/cypress/results/pass_2025-12-19T160903+0530-02_Verify_Invalid_Login_by_wrong_password.json +106 -0
- package/cypress/results/pass_2025-12-19T160905+0530-03_Verify_Lockout_user_failed_login.json +106 -0
- package/cypress/screenshots/11_testfail.cy.js/11_failed -- 02_failed (failed) (attempt 2).png +0 -0
- package/cypress/screenshots/11_testfail.cy.js/11_failed -- 02_failed (failed).png +0 -0
- package/cypress/support/Locators/Common_Locators.js +57 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/e2e.js +43 -0
- package/cypress/support/encryption.js +45 -0
- package/cypress/support/env.js +31 -0
- package/cypress/support/interface.js +6 -0
- package/cypress/support/pageObjects/CartPage.js +56 -0
- package/cypress/support/pageObjects/CheckoutPage.js +111 -0
- package/cypress/support/pageObjects/GenerateRandomData.js +62 -0
- package/cypress/support/pageObjects/Homepage.js +92 -0
- package/cypress/support/pageObjects/navigationPage.js +44 -0
- package/cypress.config.js +44 -0
- package/mochawesome-report/assets/MaterialIcons-Regular.woff +0 -0
- package/mochawesome-report/assets/MaterialIcons-Regular.woff2 +0 -0
- package/mochawesome-report/assets/app.css +14 -0
- package/mochawesome-report/assets/app.js +2 -0
- package/mochawesome-report/assets/app.js.LICENSE.txt +55 -0
- package/mochawesome-report/assets/roboto-light-webfont.woff +0 -0
- package/mochawesome-report/assets/roboto-light-webfont.woff2 +0 -0
- package/mochawesome-report/assets/roboto-medium-webfont.woff +0 -0
- package/mochawesome-report/assets/roboto-medium-webfont.woff2 +0 -0
- package/mochawesome-report/assets/roboto-regular-webfont.woff +0 -0
- package/mochawesome-report/assets/roboto-regular-webfont.woff2 +0 -0
- package/mochawesome-report/output.html +2 -0
- package/output.json +864 -0
- package/package.json +43 -0
- package/run-parallel-cypress.js +57 -0
- package/runAllSteps.js +47 -0
- package/syncTestResultsToExcel.js +219 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"stats": {
|
|
3
|
+
"suites": 1,
|
|
4
|
+
"tests": 1,
|
|
5
|
+
"passes": 1,
|
|
6
|
+
"pending": 0,
|
|
7
|
+
"failures": 0,
|
|
8
|
+
"start": "2025-12-19T10:39:04.027Z",
|
|
9
|
+
"end": "2025-12-19T10:39:05.830Z",
|
|
10
|
+
"duration": 1803,
|
|
11
|
+
"testsRegistered": 1,
|
|
12
|
+
"passPercent": 100,
|
|
13
|
+
"pendingPercent": 0,
|
|
14
|
+
"other": 0,
|
|
15
|
+
"hasOther": false,
|
|
16
|
+
"skipped": 0,
|
|
17
|
+
"hasSkipped": false
|
|
18
|
+
},
|
|
19
|
+
"results": [
|
|
20
|
+
{
|
|
21
|
+
"uuid": "50c60f25-5fe4-4219-91e3-de9db032d272",
|
|
22
|
+
"title": "",
|
|
23
|
+
"fullFile": "cypress\\e2e\\Login_Testcases\\03_Verify_Lockout_user_failed_login.cy.js",
|
|
24
|
+
"file": "cypress\\e2e\\Login_Testcases\\03_Verify_Lockout_user_failed_login.cy.js",
|
|
25
|
+
"beforeHooks": [],
|
|
26
|
+
"afterHooks": [],
|
|
27
|
+
"tests": [],
|
|
28
|
+
"suites": [
|
|
29
|
+
{
|
|
30
|
+
"uuid": "db3e828e-b83f-4bcb-bf8f-b45e73a42465",
|
|
31
|
+
"title": "03_Verify_Lockout_user_failed_login",
|
|
32
|
+
"fullFile": "",
|
|
33
|
+
"file": "",
|
|
34
|
+
"beforeHooks": [],
|
|
35
|
+
"afterHooks": [],
|
|
36
|
+
"tests": [
|
|
37
|
+
{
|
|
38
|
+
"title": "03_Verify_Lockout_user_failed_login",
|
|
39
|
+
"fullTitle": "03_Verify_Lockout_user_failed_login 03_Verify_Lockout_user_failed_login",
|
|
40
|
+
"timedOut": null,
|
|
41
|
+
"duration": 1061,
|
|
42
|
+
"state": "passed",
|
|
43
|
+
"speed": "fast",
|
|
44
|
+
"pass": true,
|
|
45
|
+
"fail": false,
|
|
46
|
+
"pending": false,
|
|
47
|
+
"context": null,
|
|
48
|
+
"code": "//login with valid user\n_navigationPage.NavigationPage.loginWithCredentials(Locket_out_User);\n//verify the home is visble \n_navigationPage.NavigationPage.verifyLoginErrorPopup(ErrorText);",
|
|
49
|
+
"err": {},
|
|
50
|
+
"uuid": "c929854b-f2ac-4b84-bbea-8c8ec57cd022",
|
|
51
|
+
"parentUUID": "db3e828e-b83f-4bcb-bf8f-b45e73a42465",
|
|
52
|
+
"isHook": false,
|
|
53
|
+
"skipped": false
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"suites": [],
|
|
57
|
+
"passes": [
|
|
58
|
+
"c929854b-f2ac-4b84-bbea-8c8ec57cd022"
|
|
59
|
+
],
|
|
60
|
+
"failures": [],
|
|
61
|
+
"pending": [],
|
|
62
|
+
"skipped": [],
|
|
63
|
+
"duration": 1061,
|
|
64
|
+
"root": false,
|
|
65
|
+
"rootEmpty": false,
|
|
66
|
+
"_timeout": 2000
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"passes": [],
|
|
70
|
+
"failures": [],
|
|
71
|
+
"pending": [],
|
|
72
|
+
"skipped": [],
|
|
73
|
+
"duration": 0,
|
|
74
|
+
"root": true,
|
|
75
|
+
"rootEmpty": true,
|
|
76
|
+
"_timeout": 2000
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"meta": {
|
|
80
|
+
"mocha": {
|
|
81
|
+
"version": "7.2.0"
|
|
82
|
+
},
|
|
83
|
+
"mochawesome": {
|
|
84
|
+
"options": {
|
|
85
|
+
"quiet": false,
|
|
86
|
+
"reportFilename": "[status]_[datetime]-[name]",
|
|
87
|
+
"saveHtml": false,
|
|
88
|
+
"saveJson": true,
|
|
89
|
+
"consoleReporter": "spec",
|
|
90
|
+
"useInlineDiffs": false,
|
|
91
|
+
"code": true
|
|
92
|
+
},
|
|
93
|
+
"version": "7.1.3"
|
|
94
|
+
},
|
|
95
|
+
"marge": {
|
|
96
|
+
"options": {
|
|
97
|
+
"reportDir": "./cypress/results",
|
|
98
|
+
"reportFilename": "[status]_[datetime]-[name]",
|
|
99
|
+
"overwrite": true,
|
|
100
|
+
"html": false,
|
|
101
|
+
"json": true
|
|
102
|
+
},
|
|
103
|
+
"version": "6.2.0"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class Common_Locators {
|
|
2
|
+
//locators form the login page
|
|
3
|
+
static Login_Page_Locators = {
|
|
4
|
+
USER_NAME: '[id="user-name"]',
|
|
5
|
+
PASSWORD: '[id="password"]',
|
|
6
|
+
LOGIN_BTN: '[id="login-button"]',
|
|
7
|
+
PAGE_TITLE: '[class="login_logo"]',
|
|
8
|
+
LOGIN_ERROR_POPUP: 'h3[data-test="error"]'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//locators form the Home page
|
|
12
|
+
static Home_Page_Locators = {
|
|
13
|
+
HOME_LOGO: '[class="app_logo"]',
|
|
14
|
+
Product_Container: '[class="inventory_item_description"]',
|
|
15
|
+
Product_Name: '[class="inventory_item"] [class*="inventory_item_name"]',
|
|
16
|
+
Add_To_Cart_Button: '[class="btn btn_primary btn_small btn_inventory "]',
|
|
17
|
+
Cart_Quantity_Number: '[id="shopping_cart_container"] span',
|
|
18
|
+
Cart_Icon: '[id="shopping_cart_container"] [class="shopping_cart_link"]',
|
|
19
|
+
Remove_From_Cart: '[class="btn btn_secondary btn_small btn_inventory "]'
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static Cart_Page_locators = {
|
|
24
|
+
Cart_Page_title: '[class="title"]',
|
|
25
|
+
Cart_Container: '[class="cart_item"]',
|
|
26
|
+
Product_Name_Cart: '[class="inventory_item_name"]',
|
|
27
|
+
Cart_Page_Remove_Btn: '[class="btn btn_secondary btn_small cart_button"]',
|
|
28
|
+
Checkout_Button: '[id="checkout"]'
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static LogOut = {
|
|
33
|
+
sidebar: '[id="react-burger-menu-btn"]',
|
|
34
|
+
Logout: '[id="logout_sidebar_link"]'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static Checkout_page_locators = {
|
|
38
|
+
checkout_page_title:'[class="title"]',
|
|
39
|
+
firstname: '[id="first-name"]',
|
|
40
|
+
lastname: '[id="last-name"]',
|
|
41
|
+
zip: '[id="postal-code"]',
|
|
42
|
+
continue_btn: '[id="continue"]',
|
|
43
|
+
cancel_btn: '[id="cancel"]',
|
|
44
|
+
Finish_btn:'[id="finish"]',
|
|
45
|
+
Product_in_Checkout:'[class="cart_item"] [class="inventory_item_name"]',
|
|
46
|
+
Checkout_Product_Container:'[class="cart_item"]',
|
|
47
|
+
Product_Price:'[class="inventory_item_price"]',
|
|
48
|
+
Checkout_Summary_Product_Price:'[data-test="subtotal-label"]',
|
|
49
|
+
Checkout_Summary_Tax_Price:'[data-test="tax-label"]',
|
|
50
|
+
Checkout_Summary_Total_Price:'[data-test="total-label"]',
|
|
51
|
+
Successful_purchase_text:'[class="complete-header"]',
|
|
52
|
+
Error_Text:'[data-test="error"]'
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
export { Common_Locators };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ***********************************************
|
|
2
|
+
// This example commands.js shows you how to
|
|
3
|
+
// create various custom commands and overwrite
|
|
4
|
+
// existing commands.
|
|
5
|
+
//
|
|
6
|
+
// For more comprehensive examples of custom
|
|
7
|
+
// commands please read more here:
|
|
8
|
+
// https://on.cypress.io/custom-commands
|
|
9
|
+
// ***********************************************
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
// -- This is a parent command --
|
|
13
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// -- This is a child command --
|
|
17
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// -- This is a dual command --
|
|
21
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
// -- This will overwrite an existing command --
|
|
25
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
///<reference types="cypress"/>
|
|
19
|
+
//handle alert
|
|
20
|
+
Cypress.on('window:alert', (alertText) => {
|
|
21
|
+
Cypress.log({
|
|
22
|
+
name: 'window:alert',
|
|
23
|
+
message: alertText
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const grep = Cypress.env('grep'); // get --env grep value
|
|
28
|
+
|
|
29
|
+
before(function() {
|
|
30
|
+
if (grep) {
|
|
31
|
+
cy.log(`Filtering tests by tag: ${grep}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
beforeEach(function() {
|
|
36
|
+
if (grep) {
|
|
37
|
+
const testTitle = Cypress.currentTest.title;
|
|
38
|
+
if (!testTitle.includes(grep)) {
|
|
39
|
+
this.skip();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class encryption {
|
|
2
|
+
// this methode encodes a string
|
|
3
|
+
encode(string) {
|
|
4
|
+
const passPhrase = 5;
|
|
5
|
+
let encodedString = "";
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < string.length; i++) {
|
|
8
|
+
let ch = string[i];
|
|
9
|
+
let code = ch.charCodeAt(0);
|
|
10
|
+
|
|
11
|
+
if (code >= 97 && code <= 122) { // a–z
|
|
12
|
+
let shifted = ((code - 97 + passPhrase) % 26) + 97;
|
|
13
|
+
encodedString += String.fromCharCode(shifted);
|
|
14
|
+
} else {
|
|
15
|
+
// Non-lowercase letter, leave unchanged
|
|
16
|
+
encodedString += ch;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return encodedString;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// this method decodes a string
|
|
24
|
+
decode(codedString) {
|
|
25
|
+
const passPhrase = 5;
|
|
26
|
+
let decodedString = "";
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < codedString.length; i++) {
|
|
29
|
+
let ch = codedString[i];
|
|
30
|
+
let code = ch.charCodeAt(0);
|
|
31
|
+
|
|
32
|
+
if (code >= 97 && code <= 122) { // a–z
|
|
33
|
+
let shifted = ((code - 97 - passPhrase + 26) % 26) + 97;
|
|
34
|
+
decodedString += String.fromCharCode(shifted);
|
|
35
|
+
} else {
|
|
36
|
+
// Non-lowercase letter, leave unchanged
|
|
37
|
+
decodedString += ch;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return decodedString;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const crypt = new encryption();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class ENV {
|
|
2
|
+
//get the credentials
|
|
3
|
+
getCredentials(type) {
|
|
4
|
+
let credentials = {};
|
|
5
|
+
//standard user
|
|
6
|
+
if (type === "standard_user") {
|
|
7
|
+
credentials["username"] = "standard_user",
|
|
8
|
+
credentials["password"] = "xjhwjy_xfzhj"
|
|
9
|
+
return credentials;
|
|
10
|
+
}
|
|
11
|
+
//invalid user
|
|
12
|
+
if (type === "locked_out_user") {
|
|
13
|
+
credentials["username"] = "locked_out_user",
|
|
14
|
+
credentials["password"] = "xjhwjy_xfzhj"
|
|
15
|
+
return credentials;
|
|
16
|
+
}
|
|
17
|
+
//error_user
|
|
18
|
+
if (type === "error_user") {
|
|
19
|
+
credentials["username"] = "error_user",
|
|
20
|
+
credentials["password"] = "xjhwjy_xfzhj"
|
|
21
|
+
return credentials;
|
|
22
|
+
}
|
|
23
|
+
//invalid user
|
|
24
|
+
if (type === "Invalid_user") {
|
|
25
|
+
credentials["username"] = "standard_user",
|
|
26
|
+
credentials["password"] = "xjhwjy_xfzhjjjs"
|
|
27
|
+
return credentials;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const env = new ENV()
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Common_Locators } from "../Locators/Common_Locators";
|
|
2
|
+
class CartPage {
|
|
3
|
+
|
|
4
|
+
// the method verify the cart page is open
|
|
5
|
+
verifytheCartpageOpened() {
|
|
6
|
+
cy.url().should("contains", "/cart.html")
|
|
7
|
+
cy.get(Common_Locators.Cart_Page_locators.Cart_Page_title).should("have.text", "Your Cart")
|
|
8
|
+
cy.log("Verified the Cart page Opened");
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// verify remove Product from cart
|
|
14
|
+
VerifyAddedItemtoCart(Product_Name) {
|
|
15
|
+
cy.get('body').then(($body) => {
|
|
16
|
+
//product name css+jquery selector
|
|
17
|
+
const productElem = $body.find(`${Common_Locators.Cart_Page_locators.Product_Name_Cart}:contains("${Product_Name}")`);
|
|
18
|
+
if (productElem.length > 0) {
|
|
19
|
+
// Wrap the found element and click Add to Cart
|
|
20
|
+
cy.wrap(productElem).parents(Common_Locators.Cart_Page_locators.Cart_Container).find(Common_Locators.Cart_Page_locators.Cart_Page_Remove_Btn).then(($el) => {
|
|
21
|
+
let text = $el.text()
|
|
22
|
+
expect(text).to.eq("Remove")
|
|
23
|
+
})
|
|
24
|
+
cy.log(`Remove button for product: ${Product_Name} is visible`);
|
|
25
|
+
} else {
|
|
26
|
+
cy.log(`Product not found: ${Product_Name}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//
|
|
31
|
+
|
|
32
|
+
//remove Product from cart
|
|
33
|
+
RemoveItemfromCart(Product_Name) {
|
|
34
|
+
cy.get('body').then(($body) => {
|
|
35
|
+
//product name selector
|
|
36
|
+
const productElem = $body.find(`${Common_Locators.Cart_Page_locators.Product_Name_Cart}:contains("${Product_Name}")`);
|
|
37
|
+
if (productElem.length > 0) {
|
|
38
|
+
// Wrap the found element and click Add to Cart
|
|
39
|
+
cy.wrap(productElem).parents(Common_Locators.Cart_Page_locators.Cart_Container).find(Common_Locators.Cart_Page_locators.Cart_Page_Remove_Btn).click({ force: true })
|
|
40
|
+
cy.log(`product: ${Product_Name} removed form the cart`);
|
|
41
|
+
} else {
|
|
42
|
+
cy.log(`Product not found: ${Product_Name}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//click on checkout button
|
|
48
|
+
clickOnCheckoutButton(){
|
|
49
|
+
cy.get(Common_Locators.Cart_Page_locators.Checkout_Button).click({force:true})
|
|
50
|
+
cy.wait(1000)
|
|
51
|
+
cy.url().should("contains", "/checkout-step-one.html")
|
|
52
|
+
cy.log("checkout Page opened")
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export const cartpage = new CartPage();
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Common_Locators } from "../Locators/Common_Locators";
|
|
2
|
+
import { Datacells } from "../interface";
|
|
3
|
+
class CheckoutPage {
|
|
4
|
+
//method verifies checkout page opened
|
|
5
|
+
verifytheCheckoutpageOpened() {
|
|
6
|
+
cy.url().should("contains", "/checkout-step-one.html")
|
|
7
|
+
cy.get(Common_Locators.Checkout_page_locators.checkout_page_title).should("have.text", "Checkout: Your Information")
|
|
8
|
+
cy.log("Verified the checkout page Opened");
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//method used to enter the information for checkout
|
|
13
|
+
enterDetailsforCheckout(dataparameters) {
|
|
14
|
+
for (const locator in dataparameters) {
|
|
15
|
+
if (dataparameters[locator]) {
|
|
16
|
+
cy.get(locator).type(dataparameters[locator]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//click on continue button
|
|
22
|
+
clickOnContinueButton() {
|
|
23
|
+
cy.get(Common_Locators.Checkout_page_locators.continue_btn).click({ force: true });
|
|
24
|
+
// if Error message is present
|
|
25
|
+
cy.get('body').then(($body) => {
|
|
26
|
+
if ($body.find(Common_Locators.Checkout_page_locators.Error_Text).length > 0) {
|
|
27
|
+
cy.get(Common_Locators.Checkout_page_locators.Error_Text)
|
|
28
|
+
.should('be.visible')
|
|
29
|
+
.and('contain.text', 'Error:');
|
|
30
|
+
cy.log('Error: Please enter correct information');
|
|
31
|
+
} else {
|
|
32
|
+
// No error message
|
|
33
|
+
cy.url().should('include', '/checkout-step-two.html');
|
|
34
|
+
cy.log('Step 2 checkout page opened');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// method is used to click on the finish button
|
|
40
|
+
clickOnFinishButton() {
|
|
41
|
+
cy.get(Common_Locators.Checkout_page_locators.Finish_btn).click({ force: true })
|
|
42
|
+
cy.wait(1000)
|
|
43
|
+
cy.url().should("contains", "/checkout-complete.html")
|
|
44
|
+
cy.log("Order Sucessfully Placed")
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// verify the product present in the final checkout page
|
|
49
|
+
VerifyProductNameAndPriceInFinalStep(Product_Name, Price) {
|
|
50
|
+
cy.get('body').then(($body) => {
|
|
51
|
+
//product name css+jquery selector
|
|
52
|
+
const productElem = $body.find(`${Common_Locators.Checkout_page_locators.Product_in_Checkout}:contains("${Product_Name}")`);
|
|
53
|
+
if (productElem.length > 0) {
|
|
54
|
+
// Wrap the found element and click Add to Cart
|
|
55
|
+
cy.wrap(productElem).parents(Common_Locators.Cart_Page_locators.Cart_Container).find(Common_Locators.Checkout_page_locators.Product_Price).then(($el) => {
|
|
56
|
+
let text = $el.text()
|
|
57
|
+
expect(text).to.include(Price)
|
|
58
|
+
})
|
|
59
|
+
cy.log(`${Product_Name} is visible and the price is ${Price}`);
|
|
60
|
+
} else {
|
|
61
|
+
cy.log(`Product not found: ${Product_Name}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
verifyTotalPriceToPay() {
|
|
67
|
+
// get the item total
|
|
68
|
+
cy.get(Common_Locators.Checkout_page_locators.Checkout_Summary_Product_Price).then((itemText) => {
|
|
69
|
+
let ItemPriceText = itemText.text()
|
|
70
|
+
const itemTotal = parseFloat(ItemPriceText.replace('Item total: $', '').trim());
|
|
71
|
+
//get the tax price
|
|
72
|
+
cy.get(Common_Locators.Checkout_page_locators.Checkout_Summary_Tax_Price)
|
|
73
|
+
.then((taxText) => {
|
|
74
|
+
let TaxText = taxText.text()
|
|
75
|
+
const tax = parseFloat(TaxText.replace('Tax: $', '').trim());
|
|
76
|
+
// Calculate the total
|
|
77
|
+
const Total = parseFloat((itemTotal + tax).toFixed(2));
|
|
78
|
+
// Retrieve the displayed total
|
|
79
|
+
cy.get(Common_Locators.Checkout_page_locators.Checkout_Summary_Total_Price)
|
|
80
|
+
.then((totalText) => {
|
|
81
|
+
let Totalpr = totalText.text()
|
|
82
|
+
const displayedTotal = parseFloat(Totalpr.replace('Total: $', '').trim());
|
|
83
|
+
expect(displayedTotal).to.equal(Total);
|
|
84
|
+
cy.log(`Total price verified: $${displayedTotal}`);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//verify the purchase was success
|
|
91
|
+
VerifyPurchase_Success() {
|
|
92
|
+
cy.get(Common_Locators.Checkout_page_locators.Successful_purchase_text).should('be.visible').and('contain.text', 'Thank you for your order!')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//verify the error pop up is displayed
|
|
96
|
+
VerifyError_Pop_up() {
|
|
97
|
+
cy.get(Common_Locators.Checkout_page_locators.Error_Text).should("be.visible").and("contain.text", 'Error:')
|
|
98
|
+
cy.log("Error Please enter Correct Information")
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// method is used to click on the finish button
|
|
103
|
+
clickOnCancelButton() {
|
|
104
|
+
cy.get(Common_Locators.Checkout_page_locators.cancel_btn).click({ force: true })
|
|
105
|
+
cy.wait(1000)
|
|
106
|
+
cy.url().should("contains", "/cart.html")
|
|
107
|
+
cy.log(" redirect Sucessfully to Cart Page")
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export const checkout_page = new CheckoutPage();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Common_Locators } from "../Locators/Common_Locators";
|
|
2
|
+
import { Datacells } from "../interface";
|
|
3
|
+
class GenerateRandomData {
|
|
4
|
+
// genraterandomString.js
|
|
5
|
+
|
|
6
|
+
genraterandomString(length, options = {}) {
|
|
7
|
+
if (!Number.isInteger(length) || length <= 0) {
|
|
8
|
+
throw new Error('Length must be a positive integer');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
includeUppercase = true,
|
|
13
|
+
includeLowercase = true,
|
|
14
|
+
includeNumbers = true,
|
|
15
|
+
includeSymbols = false,
|
|
16
|
+
excludeSimilar = false,
|
|
17
|
+
} = options;
|
|
18
|
+
|
|
19
|
+
let chars = '';
|
|
20
|
+
if (includeUppercase) chars += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
21
|
+
if (includeLowercase) chars += 'abcdefghijklmnopqrstuvwxyz';
|
|
22
|
+
if (includeNumbers) chars += '0123456789';
|
|
23
|
+
if (includeSymbols) chars += '!@#$%^&*()-_=+[]{};:,.<>?';
|
|
24
|
+
|
|
25
|
+
if (excludeSimilar) {
|
|
26
|
+
chars = chars.replace(/[O0Il]/g, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!chars) {
|
|
30
|
+
throw new Error('At least one character set must be enabled');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const cryptoAPI =
|
|
34
|
+
typeof globalThis.crypto !== 'undefined' && globalThis.crypto.getRandomValues
|
|
35
|
+
? globalThis.crypto
|
|
36
|
+
: require('crypto').webcrypto;
|
|
37
|
+
|
|
38
|
+
const result = [];
|
|
39
|
+
const randomBuffer = new Uint32Array(length);
|
|
40
|
+
cryptoAPI.getRandomValues(randomBuffer);
|
|
41
|
+
|
|
42
|
+
const max = Math.floor(0xFFFFFFFF / chars.length) * chars.length;
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < randomBuffer.length; i++) {
|
|
45
|
+
let value = randomBuffer[i];
|
|
46
|
+
while (value >= max) {
|
|
47
|
+
value = cryptoAPI.getRandomValues(new Uint32Array(1))[0];
|
|
48
|
+
}
|
|
49
|
+
result.push(chars[value % chars.length]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result.join('');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
// Example usage
|
|
58
|
+
console.log(genraterandomString(5, { includeSymbols: false, excludeSimilar: true }));
|
|
59
|
+
|
|
60
|
+
*/
|
|
61
|
+
}
|
|
62
|
+
export const generateRandomData = new GenerateRandomData();
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Common_Locators } from "../Locators/Common_Locators";
|
|
2
|
+
class Homepage {
|
|
3
|
+
|
|
4
|
+
verifyHomepage() {
|
|
5
|
+
cy.url().should("contains", "/inventory.html")
|
|
6
|
+
cy.title().should("eq", "Swag Labs")
|
|
7
|
+
cy.log("Verified the Homepage is Opened");
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// Add to Product to cart
|
|
13
|
+
AddingItemtoCart(Product_Name) {
|
|
14
|
+
cy.get('body').then(($body) => {
|
|
15
|
+
//product name selector
|
|
16
|
+
const productElem = $body.find(`${Common_Locators.Home_Page_Locators.Product_Name}:contains("${Product_Name}")`);
|
|
17
|
+
console.log(productElem)
|
|
18
|
+
if (productElem.length > 0) {
|
|
19
|
+
// Wrap the found element and click Add to Cart
|
|
20
|
+
cy.wrap(productElem).parents(Common_Locators.Home_Page_Locators.Product_Container).find(Common_Locators.Home_Page_Locators.Add_To_Cart_Button).click({ force: true });
|
|
21
|
+
cy.log(`Clicked Add to Cart for product: ${Product_Name}`);
|
|
22
|
+
} else {
|
|
23
|
+
cy.log(`Product not found: ${Product_Name}`);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//this method verifies the number of item present in the cart
|
|
29
|
+
verifyCartIconQuantity(expectedCount) {
|
|
30
|
+
if (expectedCount > 0) {
|
|
31
|
+
cy.get(Common_Locators.Home_Page_Locators.Cart_Quantity_Number, { timeout: 10000 }).should('be.visible').then(text => {
|
|
32
|
+
const Text = Number(text.text().trim())
|
|
33
|
+
expect(Text).to.eq(expectedCount);
|
|
34
|
+
});
|
|
35
|
+
cy.log(`Cart count is ${expectedCount}`);
|
|
36
|
+
}
|
|
37
|
+
if (expectedCount == 0) {
|
|
38
|
+
cy.get(Common_Locators.Home_Page_Locators.Cart_Quantity_Number, { timeout: 10000 }).should('not.exist')
|
|
39
|
+
cy.log('NO Cart icon badge');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//verify remove item btn visible form the same element
|
|
44
|
+
verifyRemovefromCartButton(Product_Name) {
|
|
45
|
+
cy.get('body').then(($body) => {
|
|
46
|
+
//product name selector
|
|
47
|
+
const productElem = $body.find(`${Common_Locators.Home_Page_Locators.Product_Name}:contains("${Product_Name}")`);
|
|
48
|
+
if (productElem.length > 0) {
|
|
49
|
+
// Wrap the found element and click Add to Cart
|
|
50
|
+
cy.wrap(productElem).parents(Common_Locators.Home_Page_Locators.Product_Container).find(Common_Locators.Home_Page_Locators.Remove_From_Cart).then(($el) => {
|
|
51
|
+
let text = $el.text()
|
|
52
|
+
expect(text).to.eq("Remove")
|
|
53
|
+
})
|
|
54
|
+
cy.log(`Remove button for product: ${Product_Name} is visible`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
//click on the cart icon
|
|
61
|
+
ClickonCartBtn() {
|
|
62
|
+
cy.get(Common_Locators.Home_Page_Locators.Cart_Icon).click({ force: true });
|
|
63
|
+
cy.wait(500)
|
|
64
|
+
cy.url().should("contains", "/cart.html")
|
|
65
|
+
cy.log("The Cart Window is opened")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//logout
|
|
69
|
+
logout() {
|
|
70
|
+
cy.get(Common_Locators.LogOut.sidebar).click({ force: true })
|
|
71
|
+
cy.get(Common_Locators.LogOut.Logout).should("have.text", "Logout")
|
|
72
|
+
cy.get(Common_Locators.LogOut.Logout).click({ force: true })
|
|
73
|
+
cy.log(`Logged Out`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//verify the products page is opened and product are displayed
|
|
77
|
+
verifyProductsPage() {
|
|
78
|
+
cy.url().should("contains", "/inventory.html")
|
|
79
|
+
cy.get(Common_Locators.Home_Page_Locators.Product_Container).should("be.visible")
|
|
80
|
+
cy.log("Products page is opened and products are displayed");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//verify minimum 6 products are displayed
|
|
84
|
+
verifyMinimumProductsDisplayed(minCount = 6) {
|
|
85
|
+
cy.wait(1000); // Wait for products to load
|
|
86
|
+
cy.get(Common_Locators.Home_Page_Locators.Product_Container).should("be.visible");
|
|
87
|
+
// Check if the number of products displayed is greater than or equal to minCount
|
|
88
|
+
cy.get(Common_Locators.Home_Page_Locators.Product_Container).should("have.length.gte", minCount);
|
|
89
|
+
cy.log(`Verified that at least ${minCount} products are displayed`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export const homepage = new Homepage();
|