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
99set 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
4750import { 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
99102import { test , expect } from ' @playwright/test' ;
100103
101104test (' 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 )
112128folder of Taurus's repo.
113129
0 commit comments