Skip to content

Commit 4a690ee

Browse files
committed
Adding README file and updating regression test
1 parent 99e0ca6 commit 4a690ee

File tree

4 files changed

+217
-9
lines changed

4 files changed

+217
-9
lines changed

‎README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# saucedemo-workspace-automation
2+
3+
## Description
4+
5+
This project is a my automatino project using mocha typescript with selenium.
6+
7+
## Getting Started
8+
9+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.Follow the steps below.
10+
11+
### Prerequisites
12+
13+
- Node.js
14+
- npm
15+
16+
### Installing
17+
18+
1. Clone the repo: `git clone https://github.com/AxelAlinsky/saucedemo-workspace-automation.git`
19+
2. Navigate to the project directory: `cd saucedemo-workspace-automation`
20+
3. Install dependencies: `npm install`
21+
4. Build project: `npm run build`
22+
23+
## Running the tests
24+
25+
`npm run regression`
26+
`npm run invalidLoginTest`
27+
`npm run restrictedAccessTest`
28+
`npm run shoppingExp`
29+
`npm run validLoginTest`

‎package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"build": "npm run clean && tsc",
88
"clean": "rimraf ./build ./package.zip",
99
"test": "_mocha ./build/test/restrictedAccessTest.js --timeout=999999 --exit",
10-
"regression": "_mocha ./build/test/regression.js --timeout=999999 --exit"
10+
"regression": "_mocha ./build/test/regression.js --timeout=999999 --exit",
11+
"invalidLoginTest": "_mocha ./build/test/invalidLoginTest.js --timeout=999999 --exit",
12+
"restrictedAccessTest": "_mocha ./build/test/restrictedAccessTest.js --timeout=999999 --exit",
13+
"shoppingExp": "_mocha ./build/test/shoppingExp.js --timeout=999999 --exit",
14+
"validLoginTest": "_mocha ./build/test/validLoginTest.js --timeout=999999 --exit"
15+
1116

1217
},
1318
"keywords": [],

‎test/regression.ts

Lines changed: 182 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,187 @@ describe('Test Case: Regression Test', async function () {
2222

2323
});
2424
// ---- Test Case 1 ----
25-
25+
describe('Test Case: Validate Unsuccessful Login', async function () {
26+
let driver: WebDriver;
27+
28+
before(async function () {
29+
driver = await App.buildDriver();
30+
driver = await new Builder().forBrowser('chrome').build();
31+
objApp = new App(driver); // Pass the driver instance here
32+
await driver.manage().window().maximize(); // Maximize the browser window
33+
});
34+
35+
after(async function () {
36+
await driver.quit(); // Close the driver after each test case
37+
});
38+
39+
it('Step 1: Open Browser', async function () {
40+
await driver.get('https://www.saucedemo.com'); // Navigate to the website
41+
42+
await objApp.verifyUrl(DataURL.saucedemo);
43+
});
44+
45+
it('Step 2: Enter invalid username', async function () {
46+
await objApp.insertText(By.css(compMain.userNameInput), 'invalid_user');
47+
});
48+
49+
it('Step 3: Enter invalid password', async function () {
50+
await objApp.insertText(By.css(compMain.userPassInput), 'wrong_password');
51+
});
52+
53+
it('Step 4: Click Login', async function () {
54+
await objApp.click(By.css(compMain.loginButton));
55+
56+
await objApp.verifyErrorMsg(`Epic sadface: Username and password do not match any user in this service`);
57+
});
58+
59+
});
2660
// ---- Test Case 2 ----
27-
61+
describe('Test Case: Retrict Direct Access', async function () {
62+
let driver: WebDriver;
63+
64+
before(async function () {
65+
driver = await App.buildDriver();
66+
driver = await new Builder().forBrowser('chrome').build();
67+
objApp = new App(driver); // Pass the driver instance here
68+
await driver.manage().window().maximize(); // Maximize the browser window
69+
});
70+
71+
after(async function () {
72+
await driver.quit(); // Close the driver after each test case
73+
});
74+
75+
it('Step 1: Directly Access to Inventory', async function () {
76+
await driver.get('https://www.saucedemo.com/inventory.html');
77+
});
78+
79+
it('Step 2: Verify Access Restriction', async function () {
80+
await objApp.restrictedErrorMsg(`Epic sadface: You can only access '/inventory.html' when you are logged in.`);
81+
});
82+
});
83+
// ---- Test Case 3 ----
84+
describe('Test Case: Validate End-to-End Shopping Process for a Specific Product', async function () {
85+
let driver: WebDriver;
86+
87+
before(async function () {
88+
driver = await App.buildDriver();
89+
driver = await new Builder().forBrowser('chrome').build();
90+
objApp = new App(driver); // Pass the driver instance here
91+
await driver.manage().window().maximize(); // Maximize the browser window
92+
});
93+
94+
after(async function () {
95+
await driver.quit(); // Close the driver after each test case
96+
});
97+
98+
it('Step 1: Open Browser', async function () {
99+
await driver.get('https://www.saucedemo.com'); // Navigate to the website
100+
101+
await objApp.verifyUrl(DataURL.saucedemo);
102+
});
103+
104+
it('Step 2: Enter valid username & password', async function () {
105+
await objApp.insertText(By.css(compMain.userNameInput), 'standard_user');
106+
107+
await objApp.insertText(By.css(compMain.userPassInput), 'secret_sauce');
108+
});
109+
110+
it('Step 3: Click Login', async function () {
111+
await objApp.click(By.css(compMain.loginButton));
112+
113+
await objApp.verifyUrl(DataURL.saucedemoInventory);
114+
});
115+
116+
it('Step 4: Click on the "Sauce Labs Backpack"', async function () {
117+
// Find the text 'Sauce Labs Backpack' and click on it
118+
await objApp.click(By.css(compMain.sauceLabsBackpack));
119+
});
120+
121+
it('Step 5: Click on the "Add to Cart" button', async function () {
122+
// Find the text 'Add to cart' and click on it
123+
await objApp.click(By.css(compMain.addToCartBtn));
124+
125+
// Verify the text 'Remove' is displayed
126+
await objApp.verifyText(By.css(compMain.removeCartBtn), 'Remove');
127+
});
128+
129+
it('Step 6: Click on the "Cart" button', async function () {
130+
// Find the text 'Cart' and click on it
131+
await objApp.click(By.css(compMain.cartBtn));
132+
133+
// Verify the text 'Your Cart' is displayed
134+
await objApp.verifyText(By.css(compMain.yourCart), 'Your Cart');
135+
136+
// Verify the cart badge is indicated as '1'
137+
await objApp.verifyText(By.css(compMain.cartBadge), '1');
138+
139+
// Verify the total item in the cart
140+
await objApp.verifyItemQty(1)
141+
});
142+
143+
it('Step 7: Click on the "Checkout" button', async function () {
144+
// Find the text 'Checkout' and click on it
145+
await objApp.click(By.css(compMain.checkoutBtn));
146+
});
147+
148+
it('Step 8: Enter Checkout Details', async function () {
149+
// Enter First Name
150+
await objApp.insertText(By.css(compMain.firstName), 'John');
151+
152+
// Enter Last Name
153+
await objApp.insertText(By.css(compMain.lastName), 'Doe');
154+
155+
// Enter Zip Code
156+
await objApp.insertText(By.css(compMain.postalCode), '12345');
157+
});
158+
159+
it('Step 9: Click on the "Continue" button', async function () {
160+
// Find the text 'Continue' and click on it
161+
await objApp.click(By.css(compMain.continueBtn));
162+
});
163+
164+
it('Step 10: Click on the "Finish" button', async function () {
165+
// Find the text 'Finish' and click on it
166+
await objApp.click(By.css(compMain.finishBtn));
167+
168+
// Verify the URL
169+
await objApp.verifyUrl(DataURL.saucedemoCheckoutComplete);
170+
171+
// Verify the text 'Thank you for your order!' is displayed
172+
await objApp.verifyText(By.css(compMain.completeHeader), 'Thank you for your order!');
173+
});
174+
});
175+
// ---- Test Case 4 ----
176+
describe('Test Case: Validate Successful Login', async function () {
177+
let driver: WebDriver;
178+
179+
before(async function () {
180+
driver = await App.buildDriver();
181+
driver = await new Builder().forBrowser('chrome').build();
182+
objApp = new App(driver); // Pass the driver instance here
183+
await driver.manage().window().maximize(); // Maximize the browser window
184+
});
185+
186+
after(async function () {
187+
await driver.quit(); // Close the driver after each test case
188+
});
189+
190+
it('Step 1: Open Browser', async function () {
191+
await driver.get('https://www.saucedemo.com'); // Navigate to the website
192+
193+
await objApp.verifyTitle();
194+
});
195+
196+
it('Step 2: Input in the application with valid username', async function () {
197+
await objApp.insertText(By.css(compMain.userNameInput), 'standard_user');
198+
});
199+
200+
it('Step 3: Input in the application with valid password', async function () {
201+
await objApp.insertText(By.css(compMain.userPassInput), 'secret_sauce ');
202+
});
203+
204+
it('Step 4: Click on the login button', async function () {
205+
await objApp.click(By.css(compMain.loginButton));
206+
});
207+
});
28208
});

‎test/shoppingExp.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ describe('Test Case: Validate End-to-End Shopping Process for a Specific Product
9999
// Verify the text 'Thank you for your order!' is displayed
100100
await objApp.verifyText(By.css(compMain.completeHeader), 'Thank you for your order!');
101101
});
102-
103-
104-
105-
106-
107-
108102
});
109103

110104

0 commit comments

Comments
 (0)