Skip to content

Commit 700af6c

Browse files
committed
Playwright_1.35.1_ENV_Var_Changes
1 parent 5f25aaf commit 700af6c

File tree

5 files changed

+338
-373
lines changed

5 files changed

+338
-373
lines changed

Diff for: Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/playwright:v1.31.0-focal
1+
FROM mcr.microsoft.com/playwright:v1.35.0-jammy
22

33
WORKDIR /app
44

@@ -20,4 +20,4 @@ RUN chown -R turing /app
2020
#Switching from root user to non-root user(turing)
2121
USER turing
2222

23-
CMD npx cross-env ENV=qa npm run test:serial
23+
CMD npm run test:serial --ENV="qa"

Diff for: README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,31 @@ npx playwright install
125125
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`:
126126

127127
```JS
128-
npx cross-env ENV=qa npm run test
128+
npm run test --ENV="qa"
129129
```
130130

131131
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`.
132132

133133
```JS
134-
npx cross-env ENV=qa npm run test:single
134+
npm run test:single --ENV="qa"
135135
```
136136

137137
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 :
138138

139139
```JS
140-
npx cross-env ENV=qa npm run test:parallel
140+
npm run test:parallel --ENV="qa"
141141
```
142142

143143
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 :
144144

145145
```JS
146-
npx cross-env ENV=qa npm run test:serial
146+
npm run test:serial --ENV="qa"
147147
```
148148

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

151151
```JS
152-
npx cross-env ENV=qaApi npm run test:api
152+
npm run test:api --ENV="qaApi"
153153
```
154154

155155
7. For recording test scripts :
@@ -161,13 +161,13 @@ npm run test:record
161161
8. To produce and visually compare screenshots execute below command. On first execution reference screenshot will be generated for comparision with subsequent runs.
162162

163163
```JS
164-
npx cross-env ENV=qa npm run test:visual
164+
npm run test:visual --ENV="qa"
165165
```
166166

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

169169
```JS
170-
npx cross-env ENV=qa npm run test:device
170+
npm run test:device --ENV="qa"
171171
```
172172

173173
10. For Allure Report generation execute :
@@ -226,7 +226,7 @@ Once logger object is created you can use this instead of console.log in your fr
226226

227227
23. 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
228228
```JS
229-
npx cross-env ENV=qa npm run test:ui
229+
npm run test:ui --ENV="qa"
230230
```
231231
24. 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.
232232

@@ -281,7 +281,7 @@ docker run --name playContainer playtest
281281
- If you want to run a different test or provide custom command, Go to Dockerfile and edit the last line which is CMD section. The below sample runs test cases serially on QA environment.
282282
Once you have edited the CMD section we have to follow Step 1 to build a new image and ten run the Container from that image.
283283
```JS
284-
CMD npx cross-env ENV=qa npm run test:serial
284+
CMD npm run test:serial --ENV="qa"
285285
```
286286

287287
## Lighthouse

0 commit comments

Comments
 (0)