You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4. For MAC and Ubuntu OS before running please exexute below code as per your environment qa|dev
127
-
```sh
128
-
export npm_config_ENV="qa"
129
-
```
130
126
131
127
<!-- USAGE EXAMPLES-->
132
128
133
129
## Usage
134
130
135
131
1. For Browser Configuration, change required parameters in `playwright.config.ts`.
136
-
2. For execution entire test suite on all available browsers simultaneously execute below command where "ENV" can be "qa" or "dev", `Test Cases are present in "tests" folder`:
132
+
2. For execution entire test suite on all available browsers simultaneously execute below command where "ENV" can be "qa" or "dev", `Test Cases are present in "tests" folder`. **You must provide the ENV variable:**
137
133
138
-
```JS
139
-
npm run test --ENV="qa"
134
+
**Windows CMD:**
135
+
```batch
136
+
set ENV=qa && npm run test
137
+
```
138
+
139
+
**Windows PowerShell:**
140
+
```powershell
141
+
$env:ENV="qa"; npm run test
142
+
```
143
+
144
+
**Mac/Linux/WSL:**
145
+
```bash
146
+
ENV=qa npm run test
140
147
```
141
148
142
149
3. For executing single test case on Chrome browser execute the below command, you can change the browser for execution e.g. if you want to run test cases on Firefox, you can change `--project=Firefox` against `test:single` in `package.json`, just make sure the browser name given matches the name given in `playwright.config.ts`.
143
150
144
-
```JS
145
-
npm run test:single --ENV="qa"
151
+
**Windows CMD:**
152
+
```batch
153
+
set ENV=qa && npm run test:single
154
+
```
155
+
156
+
**Windows PowerShell:**
157
+
```powershell
158
+
$env:ENV="qa"; npm run test:single
159
+
```
160
+
161
+
**Mac/Linux/WSL:**
162
+
```bash
163
+
ENV=qa npm run test:single
146
164
```
147
165
148
166
4. For executing test cases in parallel, provide a suitable tag `@SmokeTest` at the start of your test case name, then in `package.json` against `test:parallel` give the tag value and execute :
149
167
150
-
```JS
151
-
npm run test:parallel --ENV="qa"
168
+
**Windows CMD:**
169
+
```batch
170
+
set ENV=qa && npm run test:parallel
171
+
```
172
+
173
+
**Windows PowerShell:**
174
+
```powershell
175
+
$env:ENV="qa"; npm run test:parallel
176
+
```
177
+
178
+
**Mac/Linux/WSL:**
179
+
```bash
180
+
ENV=qa npm run test:parallel
152
181
```
153
182
154
183
5. For executing test cases in sequence, provide a suitable tag `@SmokeTest` at the start of your test case name, then in `package.json` against `test:serial` give the tag value and execute, `workers` parameter correspond to test cases you want to execute simultaneously e.g. `--workers=3`, executes 3 test cases simultaneously :
155
184
156
-
```JS
157
-
npm run test:serial --ENV="qa"
185
+
**Windows CMD:**
186
+
```batch
187
+
set ENV=qa && npm run test:serial
188
+
```
189
+
190
+
**Windows PowerShell:**
191
+
```powershell
192
+
$env:ENV="qa"; npm run test:serial
193
+
```
194
+
195
+
**Mac/Linux/WSL:**
196
+
```bash
197
+
ENV=qa npm run test:serial
158
198
```
159
199
160
200
6. For executing API test cases, please provide "ENV" value as "qaApi" or "devApi" :
161
201
162
-
```JS
163
-
npm run test:api --ENV="qaApi"
202
+
**Windows CMD:**
203
+
```batch
204
+
set ENV=qaApi && npm run test:api
205
+
```
206
+
207
+
**Windows PowerShell:**
208
+
```powershell
209
+
$env:ENV="qaApi"; npm run test:api
210
+
```
211
+
212
+
**Mac/Linux/WSL:**
213
+
```bash
214
+
ENV=qaApi npm run test:api
164
215
```
165
216
166
217
7. For recording test scripts :
@@ -171,14 +222,36 @@ npm run test:record
171
222
172
223
8. To produce and visually compare screenshots execute below command. On first execution reference screenshot will be generated for comparision with subsequent runs.
173
224
174
-
```JS
175
-
npm run test:visual --ENV="qa"
225
+
**Windows CMD:**
226
+
```batch
227
+
set ENV=qa && npm run test:visual
228
+
```
229
+
230
+
**Windows PowerShell:**
231
+
```powershell
232
+
$env:ENV="qa"; npm run test:visual
233
+
```
234
+
235
+
**Mac/Linux/WSL:**
236
+
```bash
237
+
ENV=qa npm run test:visual
176
238
```
177
239
178
240
9. For emulating test cases on any device, in `playwright.config.ts`, under device section provide desired device name and execute :
179
241
180
-
```JS
181
-
npm run test:device --ENV="qa"
242
+
**Windows CMD:**
243
+
```batch
244
+
set ENV=qa && npm run test:device
245
+
```
246
+
247
+
**Windows PowerShell:**
248
+
```powershell
249
+
$env:ENV="qa"; npm run test:device
250
+
```
251
+
252
+
**Mac/Linux/WSL:**
253
+
```bash
254
+
ENV=qa npm run test:device
182
255
```
183
256
184
257
10. For Allure Report generation execute :
@@ -235,14 +308,39 @@ Once logger object is created I have provided `logger.add(console);` which instr
235
308
Once logger object is created you can use this instead of console.log in your framework and these logs will be written both in your console and log file.
236
309
237
310
22. UI mode in Playwright is lets you explore, run and debug tests, it comes with a built-in watch mode. It opens like Traceviewer where you can use the window to find selectors, its directly integrated to VS Code, all the browsers definned in playwright config will be automatically picked up and you can chosse to run individual test cases in browser of choice and also we can run tests directly from UI mode instead of IDE. I have used the tag `@Smoke` in `test:ui` section of package.json, because all my UI test cases are tagged with `@Smoke` tag and we want to run only Web based test cases. To use UI mode use below command with `ENV` value of your choice
238
-
```JS
239
-
npm run test:ui --ENV="qa"
311
+
312
+
**Windows CMD:**
313
+
```batch
314
+
set ENV=qa && npm run test:ui
315
+
```
316
+
317
+
**Windows PowerShell:**
318
+
```powershell
319
+
$env:ENV="qa"; npm run test:ui
240
320
```
321
+
322
+
**Mac/Linux/WSL:**
323
+
```bash
324
+
ENV=qa npm run test:ui
325
+
```
326
+
241
327
23. For Extracting text from PDF we are using `pdfjs-dist-es5` library. You can run the test case `PdfToText.test.ts` to verify contents of PDF file. `getPDFText()` method in `lib/WebActions.ts` class is used for extracting text from PDF file.
242
328
243
329
24. Accessibility test case is written in `tests/accessibility/Axe.test.ts`, to run this test use the command
244
-
```JS
245
-
npm run test:accessibility --ENV="qa"
330
+
331
+
**Windows CMD:**
332
+
```batch
333
+
set ENV=qa && npm run test:accessibility
334
+
```
335
+
336
+
**Windows PowerShell:**
337
+
```powershell
338
+
$env:ENV="qa"; npm run test:accessibility
339
+
```
340
+
341
+
**Mac/Linux/WSL:**
342
+
```bash
343
+
ENV=qa npm run test:accessibility
246
344
```
247
345
248
346
25. GitHub Actions is configured in `.github/workflows/playwright.yml` file and events(trigger points) are set to pus/pull actions on master branch. Changes in command to run test cases can be made in "Run tests" section in this file.
0 commit comments