Skip to main content
Version: 1.16


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.

import { PlaywrightTestConfig } from '@playwright/test';const config: PlaywrightTestConfig = {  use: {    headless: false,    viewport: { width: 1280, height: 720 },    ignoreHTTPSErrors: true,    video: 'on-first-retry',  },};export default config;

Alternatively, with test.use(options) you can override some options for a file.

// example.spec.tsimport { test, expect } from '@playwright/test';
// Run tests in this file with portrait-like viewport.test.use({ viewport: { width: 600, height: 900 } });
test('my portrait test', async ({ page }) => {  // ...});


Whether to automatically download all the attachments. Defaults to false where all the downloads are canceled.


Default timeout for each Playwright action in milliseconds, defaults to 0 (no timeout).

This is a default timeout for all Playwright actions, same as configured via page.setDefaultTimeout(timeout).


When using page.goto(url[, options]), page.route(url, handler[, options]), page.waitForURL(url[, options]), page.waitForRequest(urlOrPredicate[, options]), or page.waitForResponse(urlOrPredicate[, options]) it takes the base URL in consideration by using the URL() constructor for building the corresponding URL. Examples:

  • baseURL: http://localhost:3000 and navigating to /bar.html results in http://localhost:3000/bar.html
  • baseURL: http://localhost:3000/foo/ and navigating to ./bar.html results in http://localhost:3000/foo/bar.html


  • type: <"chromium"|"firefox"|"webkit">

Name of the browser that runs tests. Defaults to 'chromium'. Most of the time you should set browserName in your TestConfig:

// playwright.config.tsimport { PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {  use: {    browserName: 'firefox',  },};export default config;


Toggles bypassing page's Content-Security-Policy.

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.


  • type: <"light"|"dark"|"no-preference">

Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'. See page.emulateMedia([options]) for more details. Defaults to 'light'.


Options used to create the context, as passed to browser.newContext([options]). Specific options like testOptions.viewport take priority over this.


Specify device scale factor (can be thought of as dpr). Defaults to 1.


An object containing additional HTTP headers to be sent with every request.


  • type: <Object>
    • latitude <number> Latitude between -90 and 90.
    • longitude <number> Longitude between -180 and 180.
    • accuracy <number> Non-negative accuracy value. Defaults to 0.


Specifies if viewport supports touch events. Defaults to false.


Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to true unless the devtools option is true.


Credentials for HTTP authentication.


Whether to ignore HTTPS errors when sending network requests. Defaults to false.


Whether the meta viewport tag is taken into account and touch events are enabled. Defaults to false. Not supported in Firefox.


Whether or not to enable JavaScript in the context. Defaults to true.


Options used to launch the browser, as passed to browserType.launch([options]). Specific options testOptions.headless and take priority over this.


Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules.


Timeout for each navigation action in milliseconds. Defaults to 0 (no timeout).

This is a default navigation timeout, same as configured via page.setDefaultNavigationTimeout(timeout).


Whether to emulate network being offline. Defaults to false.


A list of permissions to grant to all pages in this context. See browserContext.grantPermissions(permissions[, options]) for more details.


  • type: <Object>
    • server <string> Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example or socks5:// Short form is considered an HTTP proxy.
    • bypass <string> Optional comma-separated domains to bypass proxy, for example ".com,,".
    • username <string> Optional username to use if HTTP proxy requires authentication.
    • password <string> Optional password to use if HTTP proxy requires authentication.

Network proxy settings.


  • type: <"off"|"on"|"only-on-failure">

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.

Learn more about automatic screenshots.


Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via browserContext.storageState([options]). Either a path to the file with saved storage, or an object with the following fields:


Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs.


  • type: <"off"|"on"|"retain-on-failure"|"on-first-retry">

Whether to record a trace for each test. Defaults to 'off'.

  • 'off': Do not record a trace.
  • 'on': Record a trace for each test.
  • 'retain-on-failure': Record a trace for each test, but remove it from successful test runs.
  • 'on-first-retry': Record a trace only when retrying a test for the first time.

Learn more about recording trace.


Specific user agent to use in this context.

  • type: <Object|"off"|"on"|"retain-on-failure"|"on-first-retry">
    • mode <"off"|"on"|"retain-on-failure"|"on-first-retry"> Video recording mode.
    • size <Object> Size of the recorded video.

Whether 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.

Learn more about recording video.


Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. null disables the default viewport.