Skip to content

Commit f70509d

Browse files
fix mistakes in Playwright docs (#1959)
* MOB-45477 fix mistakes in Playwright docs * Create doc-playwright-example-update.change --------- Co-authored-by: henrychv <74781044+henrychv@users.noreply.github.com>
1 parent a9561bd commit f70509d

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

site/dat/docs/Playwright.md

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Playwright Executor
2-
Allows running tests written in TypeScript based on Playwright.
2+
Use this executor to run tests written in TypeScript based on Playwright.
33

4-
Taurus can loop test suite execution in a loop until desired number of `iterations` will complete (for each concurrent user)
5-
or hold-for time will be exceeded.
6-
Also number of concurrent users (aka workers in Playwright) can be specified using `concurrency`.
4+
Taurus can repeat test suite executions in a loop until the desired number of `iterations` is complete (for each concurrent user),
5+
or until the hold-for time is exceeded.
6+
To specifiy the number of concurrent users (also known as workers in Playwright), define the `concurrency` option.
77

8-
*NOTE*: As Playwright does not support infinite iterations if `hold-for` is used without `iterations` Taurus will
8+
*NOTE*: As Playwright does not support infinite iterations, if `hold-for` is used without `iterations`, Taurus will
99
set playwright's repeat-each to _1000_.
1010

11-
You may specify `BASE_URL` in `settings` section to be pass to your test as an environment variable.
11+
To pass the base URL to your test as an environment variable, define the `BASE_URL` option in the `settings` section.
1212

13-
It is possible to override the browser settings from your Playwright test configuration by using the `browser` option, e.g.,
14-
you may enter one of these: `chromium`, `firefox`, `webkit`.
13+
To override the browser settings from your Playwright test configuration, define the `browser` option.
14+
For example, enter one of these values: `chromium`, `firefox`, `webkit`.
1515

16-
A single test from the suite may be selected to be executed using the `test` field.
16+
To select a single test from the suite to be executed, define the `test` field.
1717

1818
## Usage
1919
```yaml
@@ -37,12 +37,15 @@ scenarios:
3737
3838
## Playwright project
3939
40-
Your project will need to consist of at least these files:
41-
* package.json - lists the dependencies of the project, these are then installed automatically when executing it using the Taurus Playwright executor
42-
* playwright.config.ts - Playwright configuration file
43-
* actual file or files with tests, see example below
40+
Your Playwright project must consist of at least these files:
41+
* package.json - Lists the dependencies of the project, these are then installed automatically when executing it using the Taurus Playwright executor
42+
* playwright.config.ts - The Playwright configuration file
43+
* example.spec.ts - The actual file or files with tests, see example below
4444
45-
Example of Playwright configuration file:
45+
Example package.json:
46+
https://github.com/Blazemeter/taurus/blob/master/examples/playwright/package.json
47+
48+
Example playwright.config.ts, the Playwright configuration file:
4649
```javascript
4750
import { defineConfig, devices } from '@playwright/test';
4851

@@ -63,7 +66,7 @@ export default defineConfig({
6366
reporter: 'json',
6467
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
6568
use: {
66-
/* Base URL to use in actions like `await page.goto('/')`. */
69+
/* Base URL to use in test actions like `await page.goto('/')`. */
6770
// baseURL: 'http://127.0.0.1:3000',
6871
baseURL: process.env.BASE_URL,
6972
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
@@ -89,25 +92,38 @@ export default defineConfig({
8992
{
9093
name: 'webkit',
9194
use: { ...devices['Desktop Safari'] },
92-
}]
95+
}
96+
],
9397
});
9498
```
9599

96-
97-
Basic example of Playwright test:
100+
Example example.spec.ts, a basic Playwright test for https://blazedemo.com/:
98101
```javascript
99102
import { test, expect } from '@playwright/test';
100103

101104
test('has title', async ({ page }) => {
102-
await page.goto("/"); // uses the BASE_URL
105+
await page.goto("/");
106+
107+
// Expect a title "to contain" a substring.
108+
await expect(page).toHaveTitle(/BlazeDemo/);
109+
});
110+
111+
test('reserve flight', async ({ page }) => {
112+
await page.goto('/');
113+
114+
await page.getByRole('button', { name: 'Find Flights' }).click();
115+
116+
await expect(page).toHaveTitle(/reserve/);
117+
118+
await page.getByRole('button', { name: 'Choose This Flight' }).nth(1).click();
119+
120+
await expect(page).toHaveTitle(/Purchase/);
103121

104-
// Expect a title "to contain" a substring.
105-
await expect(page).toHaveTitle(/BlazeDemo/);
106122
});
107123

108124
```
109125

110-
You can also find an example of the complete Playwright-based test suite and Taurus config to run it with
111-
in [examples/playwright](https://github.com/Blazemeter/taurus/tree/master/examples/playrwright)
126+
You can find this complete Playwright-based test suite and Taurus config to run it with
127+
in the [examples/playwright](https://github.com/Blazemeter/taurus/tree/master/examples/playwright)
112128
folder of Taurus's repo.
113129

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Doc: Updated and clarified Playwright code samples and folder structure in github example and on gettaurus.org, fixed typoed link, copy-edit

0 commit comments

Comments
 (0)