new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · all subjects

configuration

165 notes in this subject, read out of this brain and free to use. This is page 3 of 3.

baseURL configuration option

The baseURL option sets the base URL used for all pages in the context. It allows navigating using just the path, for example page.goto('/settings'). This is set in the use object of the Playwright config.

storageState configuration option

The storageState option populates the context with a given storage state. It is useful for easy authentication. The value can be a path to a JSON file containing the storage state.

acceptDownloads network option

The acceptDownloads option controls whether to automatically download all attachments. It defaults to true. Set in the use object of the Playwright config.

extraHTTPHeaders network option

The extraHTTPHeaders option is an object containing additional HTTP headers to be sent with every request. All header values must be strings. Example: { 'X-My-Header': 'value' }.

httpCredentials network option

The httpCredentials option provides credentials for HTTP authentication. It is an object with username and password properties. Example: { username: 'user', password: 'pass' }.

ignoreHTTPSErrors network option

The ignoreHTTPSErrors option controls whether to ignore HTTPS errors during navigation. It is a boolean set in the use object of the Playwright config.

offline network option

The offline option controls whether to emulate network being offline. It is a boolean set in the use object of the Playwright config.

proxy network option

The proxy option sets proxy settings used for all pages in the test. It is an object with server and optionally bypass properties. Example: { server: 'http://myproxy.com:3128', bypass: 'localhost' }.

video recording option values

The video option controls whether to record videos. Supported values are 'off', 'on', 'retain-on-failure', and 'on-first-retry'. It is set in the use object of the Playwright config.

video mode recording rules

Video modes use the same set as trace modes and follow the same rules. 'off': never records. 'on': records every run, keeps always. 'retain-on-failure': records every run, keeps if that run failed. 'retain-on-first-failure': records first run only, keeps if first run failed. 'retain-on-failure-and-retries': records every run, keeps if that run failed or is a retry. 'on-first-retry': records first retry only, keeps always. 'on-all-retries': records every retry, keeps always.

actionTimeout configuration option

The actionTimeout option sets the timeout for each Playwright action in milliseconds. It defaults to 0, meaning no timeout. It is set in the use object of the Playwright config.

browserName configuration option

The browserName option specifies the name of the browser that runs tests. Defaults to 'chromium'. Supported options are 'chromium', 'firefox', and 'webkit'.

bypassCSP configuration option

The bypassCSP option toggles bypassing Content-Security-Policy. It is useful when CSP includes the production origin. Defaults to false.

channel configuration option

The channel option specifies the browser channel to use. Examples include 'chrome', 'chrome-beta', 'msedge', and 'msedge-beta'. It is set in the use object of the Playwright config.

headless configuration option

The headless option controls whether to run the browser in headless mode. When headless is true, no browser window is shown when running tests. Defaults to true.

launchOptions in configuration

Any options accepted by BrowserType.launch can be put into launchOptions in the use section of the config. Example: { slowMo: 50 } passes slowMo to the launch method.

contextOptions in configuration

Any options accepted by Browser.newContext can be put into contextOptions in the use section of the config.

connectOptions in configuration

Any options accepted by BrowserType.connect can be put into connectOptions in the use section of the config.

Configuration scopes in Playwright

Configuration options can be set at three levels with increasing specificity: globally (in defineConfig use option), per project (in projects array use option), and per test (using test.use() in test files). More specific scopes override less specific ones.

Override configuration options for a specific test file

Use test.use({ option: value }) at the top of a test file to override configuration options for all tests in that file. This can also be done inside a describe block to affect only tests within that block.

Completely unset a configuration option using fixture notation

To completely unset a configuration option, use the long-form fixture notation: test.use({ option: [async ({}, use) => use(undefined), { scope: 'test' }] }). This allows clearing an option that would otherwise inherit from the config.

Example: Configure baseURL and storageState globally

export default defineConfig({ use: { baseURL: 'http://localhost:3000', storageState: 'state.json', }, });

Example: Override locale per project

import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], locale: 'de-DE', }, }, ], });

Example: Override option for a specific test

import { test, expect } from '@playwright/test'; test.use({ locale: 'fr-FR' }); test('example', async ({ page }) => { // This test runs with French locale });

Example: Override option in a describe block

import { test, expect } from '@playwright/test'; test.describe('french language block', () => { test.use({ locale: 'fr-FR' }); test('example', async ({ page }) => { // Tests in this block use French locale }); });

Example: Reset option to config value

import { test } from '@playwright/test'; test.use({ baseURL: 'https://playwright.dev/docs/intro' }); test('check intro contents', async ({ page }) => { // Uses 'https://playwright.dev/docs/intro' baseURL }); test.describe(() => { test.use({ baseURL: undefined }); test('can navigate to intro from the home page', async ({ page }) => { // Uses 'https://playwright.dev' baseURL from config }); });

Example: Completely unset a configuration option

import { test } from '@playwright/test'; test.use({ baseURL: [async ({}, use) => use(undefined), { scope: 'test' }], }); test('no base url', async ({ page }) => { // This test has no baseURL });

Example: Configure recording options

export default defineConfig({ use: { screenshot: 'only-on-failure', trace: 'on-first-retry', video: 'on-first-retry' }, });

Example: Configure network options

export default defineConfig({ use: { acceptDownloads: false, extraHTTPHeaders: { 'X-My-Header': 'value', }, httpCredentials: { username: 'user', password: 'pass', }, ignoreHTTPSErrors: true, offline: true, proxy: { server: 'http://myproxy.com:3128', bypass: 'localhost', }, }, });

Example: Configure browser and other options

export default defineConfig({ use: { actionTimeout: 0, browserName: 'chromium', bypassCSP: true, channel: 'chrome', headless: false, testIdAttribute: 'pw-test-id', }, });

Example: Configure launchOptions

export default defineConfig({ use: { launchOptions: { slowMo: 50, }, }, });

Video files output directory

Video files appear in the test output directory, typically `test-results`, when recording is enabled.

Video recording mode options in Playwright config

Playwright Test supports four video recording modes via the `video` option in the configuration: 'off' (do not record video), 'on' (record video for each test), 'retain-on-failure' (record video for each test but remove videos from successful runs), and 'on-first-retry' (record video only when retrying a test for the first time). By default, videos are off.

Video annotation with test information

When `show: { test }` is specified in the video configuration, the video will be annotated with the current test information. The `level`, `position`, and `fontSize` properties can be configured for this annotation.

Videos saved on browser context closure

Videos are saved upon browser context closure at the end of a test. If you create a browser context manually, you must await the `BrowserContext.close` method to ensure videos are saved.

Default video size in Playwright

The video size defaults to the viewport size scaled down to fit 800x800. The video of the viewport is placed in the top-left corner of the output video, scaled down to fit if necessary. You may need to set the viewport size to match your desired video size.

Record video with browser context API

When using the browser context API directly, enable video recording by passing `recordVideo: { dir: 'videos/' }` to `browser.newContext()`. Example: `const context = await browser.newContext({ recordVideo: { dir: 'videos/' } }); await context.close();`. Video files will appear in the specified folder with generated unique names.

Configure video recording with Playwright Test config

Example configuration for recording video on first retry with custom size and annotations: In `playwright.config.ts`, set `use: { video: { mode: 'on-first-retry', size: { width: 640, height: 480 }, show: { actions: { duration: 500, position: 'top-right', fontSize: 14 }, test: { level: 'step', position: 'top-left', fontSize: 12 } } } }`

Video availability after context closure

The video is only available after the page or browser context is closed.

Access video file from page object

For multi-page scenarios, you can access the video file associated with a page using the `Page.video()` method and calling `path()` on it. For example: `const path = await page.video().path();`

Video annotation with actions

When `show: { actions }` is specified in the video configuration, each action will be visually highlighted in the video with the element outline and action title subtitle. The optional `duration` property controls how long each annotation is displayed, defaulting to 500ms. The `position` and `fontSize` properties can also be configured.

Trace options in configuration

Available trace options for the `trace` property in playwright.config.ts are: 'on-first-retry' (record trace only when retrying a test for the first time), 'on-all-retries' (record traces for all test retries), 'off' (do not record a trace), 'on' (record a trace for each test, not recommended due to performance), 'retain-on-failure' (record a trace for each test but remove from successful runs).

WebView2 connects via connectOverCDP

Playwright connects to WebView2 using the connectOverCDP method, which connects via the Chrome DevTools Protocol (CDP). The WebView2 control must be configured to listen to incoming CDP connections by setting the WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS environment variable with --remote-debugging-port=9222, or by calling EnsureCoreWebView2Async with the --remote-debugging-port=9222 argument. The port 9222 is an example; any other unused port can be used.

Playwright.create() env option

The Playwright.create() method in Java accepts an optional 'env' parameter of type Object<string, string> containing additional environment variables to pass to the driver process. By default the driver process inherits environment variables of the Playwright process.

playwright-cli configuration file

Use playwright-cli open --config=my-config.json to start a browser session with a specific configuration file.

Give your agent this brain