Name of the browser that runs tests. Defaults to 'chromium'
. Most of the time you should set browserName
in
your TestConfig:
Usage
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
use: {
browserName: 'firefox',
},
});
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using Google Chrome and Microsoft Edge.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'Microsoft Edge',
use: {
...devices['Desktop Edge'],
channel: 'msedge'
},
},
]
});
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
connectOptions: {
wsEndpoint: 'ws://localhost:5678',
},
},
});
When connect options are specified, default fixtures.browser, fixtures.context and fixtures.page use the remote browser instead of launching a browser locally, and any launch options like testOptions.headless or testOptions.channel are ignored.
Options used to launch the browser, as passed to browserType.launch([options]). Specific options testOptions.headless and testOptions.channel take priority over this.
NOTE Use custom browser args at your own risk, as some of them may break Playwright functionality.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
launchOptions: {
args: ['--start-maximized']
}
}
}
]
});
Whether to automatically capture a screenshot after each test. Defaults to 'off'
.
'off'
: Do not capture screenshots.'on'
: Capture screenshot after each test.'only-on-failure'
: Capture screenshot after each test failure.Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
});
Learn more about automatic screenshots.
Whether to record trace for each test. Defaults to 'off'
.
'off'
: Do not record trace.'on'
: Record trace for each test.'on-first-retry'
: Record trace only when retrying a test for the first time.'on-all-retries'
: Record trace only when retrying a test.'retain-on-failure'
: Record trace for each test. When test run passes, remove the recorded trace.'retain-on-first-failure'
: Record trace for the first run of each test, but not for retires. When test run
passes, remove the recorded trace.For more control, pass an object that specifies mode
and trace features to enable.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
trace: 'on-first-retry'
},
});
Learn more about recording trace.
Optional
attachments?: booleanOptional
screenshots?: booleanOptional
snapshots?: booleanOptional
sources?: booleanWhether to record video for each test. Defaults to 'off'
.
'off'
: Do not record video.'on'
: Record video for each test.'retain-on-failure'
: Record video for each test, but remove all videos from successful test runs.'on-first-retry'
: Record video only when retrying a test for the first time.To control video size, pass an object with mode
and size
properties. If video size is not specified, it will be
equal to testOptions.viewport scaled
down to fit into 800x800. If viewport
is not configured explicitly the video size defaults to 800x450. Actual
picture of each page will be scaled down if necessary to fit the specified size.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
video: 'on-first-retry',
},
});
Learn more about recording video.
Optional
size?: ViewportSizeGenerated using TypeDoc
Playwright Test provides many options to configure test environment, Browser, BrowserContext and more.
These options are usually provided in the configuration file through testConfig.use and testProject.use.
Alternatively, with test.use(options) you can override some options for a file.