@@ -22,7 +22,187 @@ describe('Test Case: Regression Test', async function () {
22
22
23
23
} ) ;
24
24
// ---- 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
+ } ) ;
26
60
// ---- 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
+ } ) ;
28
208
} ) ;
0 commit comments