Skip to content

Commit b1c7790

Browse files
committed
Added croos-env
1 parent 97d9079 commit b1c7790

8 files changed

Lines changed: 6131 additions & 3470 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ test-results/
33
allure-results/
44
allure-report/
55
Downloads/
6-
html-report.zip/
6+
html-report.zip/
7+
logs/
8+
html-report/

README.md

Lines changed: 121 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,44 +123,95 @@ npm install
123123
```sh
124124
npx playwright install
125125
```
126-
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-
```
130126

131127
<!-- USAGE EXAMPLES-->
132128

133129
## Usage
134130

135131
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:**
137133

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
140147
```
141148

142149
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`.
143150

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
146164
```
147165

148166
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 :
149167

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
152181
```
153182

154183
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 :
155184

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
158198
```
159199

160200
6. For executing API test cases, please provide "ENV" value as "qaApi" or "devApi" :
161201

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
164215
```
165216

166217
7. For recording test scripts :
@@ -171,14 +222,36 @@ npm run test:record
171222

172223
8. To produce and visually compare screenshots execute below command. On first execution reference screenshot will be generated for comparision with subsequent runs.
173224

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
176238
```
177239

178240
9. For emulating test cases on any device, in `playwright.config.ts`, under device section provide desired device name and execute :
179241

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
182255
```
183256

184257
10. For Allure Report generation execute :
@@ -235,14 +308,39 @@ Once logger object is created I have provided `logger.add(console);` which instr
235308
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.
236309

237310
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
240320
```
321+
322+
**Mac/Linux/WSL:**
323+
```bash
324+
ENV=qa npm run test:ui
325+
```
326+
241327
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.
242328

243329
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
246344
```
247345

248346
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.

html-report/OrtoniHtmlReport.html

Lines changed: 0 additions & 1564 deletions
This file was deleted.

html-report/index.html

Lines changed: 0 additions & 68 deletions
This file was deleted.

logs/info.log

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)