Whether to automatically download all the attachments. Defaults to true
where all the downloads are accepted.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
acceptDownloads: false,
},
});
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).
Usage
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
},
});
Learn more about various timeouts.
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.
Unset by default. Examples:
http://localhost:3000
and navigating to /bar.html
results in http://localhost:3000/bar.html
http://localhost:3000/foo/
and navigating to ./bar.html
results in
http://localhost:3000/foo/bar.html
http://localhost:3000/foo
(without trailing slash) and navigating to ./bar.html
results in
http://localhost:3000/bar.html
Usage
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3000',
},
});
Toggles bypassing page's Content-Security-Policy. Defaults to false
.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
bypassCSP: true,
}
});
Emulates 'prefers-colors-scheme'
media feature, supported values are 'light'
, 'dark'
, 'no-preference'
. See
page.emulateMedia([options]) for more details.
Passing null
resets emulation to system defaults. Defaults to 'light'
.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
colorScheme: 'dark',
},
});
Options used to create the context, as passed to browser.newContext([options]). Specific options like testOptions.viewport take priority over this.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
contextOptions: {
reducedMotion: 'reduce',
},
},
});
Specify device scale factor (can be thought of as dpr). Defaults to 1
. Learn more about
emulating devices with device scale factor.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
viewport: { width: 2560, height: 1440 },
deviceScaleFactor: 2,
},
});
An object containing additional HTTP headers to be sent with every request. Defaults to none.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
extraHTTPHeaders: {
'X-My-Header': 'value',
},
},
});
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
geolocation: { longitude: 12.492507, latitude: 41.889938 },
},
});
Learn more about geolocation.
Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
hasTouch: true
},
});
Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
httpCredentials: {
username: 'user',
password: 'pass',
},
},
});
Whether to ignore HTTPS errors when sending network requests. Defaults to false
.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
ignoreHTTPSErrors: true,
},
});
Whether the meta viewport
tag is taken into account and touch events are enabled. isMobile is a part of device,
so you don't actually need to set it manually. Defaults to false
and is not supported in Firefox. Learn more
about mobile emulation.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
isMobile: false,
},
});
Whether or not to enable JavaScript in the context. Defaults to true
. Learn more about
disabling JavaScript.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
javaScriptEnabled: false,
},
});
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. Defaults to the system default
locale. Learn more about emulation in our emulation guide.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
locale: 'it-IT',
},
});
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).
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
navigationTimeout: 3000,
},
});
Learn more about various timeouts.
Whether to emulate network being offline. Defaults to false
. Learn more about
network emulation.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
offline: true
},
});
A list of permissions to grant to all pages in this context. See browserContext.grantPermissions(permissions[, options]) for more details. Defaults to none.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
permissions: ['notifications'],
},
});
Network proxy settings.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
proxy: {
server: 'http://myproxy.com:3128',
bypass: 'localhost',
},
},
});
Optional
bypass?: stringOptional comma-separated domains to bypass proxy, for example ".com, chromium.org, .domain.com"
.
Optional
password?: stringOptional password to use if HTTP proxy requires authentication.
Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example http://myproxy.com:3128
or
socks5://myproxy.com:3128
. Short form myproxy.com:3128
is considered an HTTP proxy.
Optional
username?: stringOptional username to use if HTTP proxy requires authentication.
Whether to allow sites to register Service workers. Defaults to 'allow'
.
'allow'
: Service Workers can be
registered.'block'
: Playwright will block all registration of Service Workers.Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
serviceWorkers: 'allow'
},
});
Learn more about storage state and auth.
Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via browserContext.storageState([options]).
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
storageState: 'storage-state.json',
},
});
Details
When storage state is set up in the config, it is possible to reset storage state for a file:
// not-signed-in.spec.ts
import { test } from '@playwright/test';
// Reset storage state for this file to avoid being authenticated
test.use({ storageState: { cookies: [], origins: [] } });
test('not signed in test', async ({ page }) => {
// ...
});
Custom attribute to be used in
page.getByTestId(testId). data-testid
is used
by default.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
testIdAttribute: 'pw-test-id',
},
});
Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
timezoneId: 'Europe/Rome',
},
});
Specific user agent to use in this context.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
userAgent: 'some custom ua',
},
});
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use null
to disable the consistent
viewport emulation. Learn more about viewport emulation.
NOTE The null
value opts out from the default presets, makes viewport depend on the host window size defined
by the operating system. It makes the execution of the tests non-deterministic.
Usage
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
viewport: { width: 100, height: 100 },
},
});
Generated 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.