new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Playwright · API reference · all subjects

method parameters & options

34 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

RequestOptions.create() static factory method

RequestOptions.create() creates a new RequestOptions instance for configuring API request parameters.

RequestOptions.setData() method

RequestOptions.setData(Map) method sets the request body data as a map of key-value pairs.

Clock.install() InstallOptions parameter with time property

In Java, Clock.InstallOptions has a setTime method: page.clock().install(new Clock.InstallOptions().setTime(format.parse('2024-02-02T08:00:00')));

Clock.PauseAtAsync in C# accepts DateTime parameter

In C#, the Clock method is PauseAtAsync and accepts a DateTime parameter: await Page.Clock.PauseAtAsync(new DateTime(2024, 2, 2, 10, 0, 0));

Clock.InstallAsync in C# accepts options with TimeDate property

In C#, Clock.InstallAsync accepts an options object with TimeDate property: await Page.Clock.InstallAsync(new() { TimeDate = new DateTime(2024, 2, 2, 8, 0, 0) });

fastForward time format - MM:SS or duration string

The fastForward method accepts a time duration in the format of minutes and seconds, such as '30:00' for 30 minutes or '05:00' for 5 minutes.

runFor parameter - milliseconds duration

The runFor method accepts a duration in milliseconds. For example, runFor(2000) advances time by 2000 milliseconds and fires all timers due in that period.

Python Clock methods - set_fixed_time, install, pause_at, fast_forward, run_for

Python Clock API uses snake_case method names: set_fixed_time (accepts datetime.datetime), install (accepts time parameter as datetime.datetime), pause_at (accepts datetime.datetime), fast_forward (accepts string like '30:00'), run_for (accepts milliseconds as integer).

TestOptions.baseURL property

The baseURL option sets the base URL used for all pages in a test context. It allows navigating by using just the path, for example page.goto('/settings'). It is configured in the use section of playwright.config.ts.

TestOptions.storageState property

The storageState option populates a context with a given storage state. This is useful for easy authentication. It is configured in the use section of playwright.config.ts.

TestOptions.colorScheme property

The colorScheme option emulates the 'prefers-colors-scheme' media feature. Supported values are 'light' and 'dark'. It is configured in the use section of playwright.config.ts.

TestOptions.geolocation property

The geolocation option sets the context geolocation. It takes an object with longitude and latitude properties. It is configured in the use section of playwright.config.ts.

TestOptions.locale property

The locale option emulates the user locale, for example 'en-GB', 'de-DE', etc. It is configured in the use section of playwright.config.ts.

TestOptions.permissions property

The permissions option is a list of permissions to grant to all pages in the context. It is configured in the use section of playwright.config.ts.

TestOptions.timezoneId property

The timezoneId option changes the timezone of the context, for example 'Europe/Paris'. It is configured in the use section of playwright.config.ts.

TestOptions.viewport property

The viewport option sets the viewport used for all pages in the context. It takes an object with width and height properties. It is configured in the use section of playwright.config.ts.

TestOptions.acceptDownloads property

The acceptDownloads option determines whether to automatically download all attachments. It defaults to true. It is configured in the use section of playwright.config.ts.

TestOptions.extraHTTPHeaders property

The extraHTTPHeaders option is an object containing additional HTTP headers to be sent with every request. All header values must be strings. It is configured in the use section of playwright.config.ts.

TestOptions.httpCredentials property

The httpCredentials option provides credentials for HTTP authentication. It is configured in the use section of playwright.config.ts.

TestOptions.ignoreHTTPSErrors property

The ignoreHTTPSErrors option determines whether to ignore HTTPS errors during navigation. It is configured in the use section of playwright.config.ts.

TestOptions.offline property

The offline option determines whether to emulate network being offline. It is configured in the use section of playwright.config.ts.

TestOptions.proxy property

The proxy option sets proxy settings used for all pages in the test. It takes an object with server and bypass properties. It is configured in the use section of playwright.config.ts.

TestOptions.screenshot property

The screenshot option captures screenshots of your test. Supported options are 'off', 'on', and 'only-on-failure'. It is configured in the use section of playwright.config.ts.

TestOptions.trace property

The trace option controls test trace recording. Playwright can produce test traces while running tests. Later, you can view the trace in Trace Viewer to get detailed information about Playwright execution. Supported options are 'off', 'on', 'retain-on-failure', and 'on-first-retry'.

TestOptions.video property

The video option controls test video recording. Playwright can record videos for your tests. Supported options are 'off', 'on', 'retain-on-failure', and 'on-first-retry'.

Trace recording modes

Trace recording modes: 'off' (never records), 'on' (every run, keeps always), 'retain-on-failure' (every run, keeps when run failed), 'retain-on-first-failure' (first run only, keeps if first run failed), 'retain-on-failure-and-retries' (every run, keeps when failed or retry), 'on-first-retry' (first retry only, keeps always), 'on-all-retries' (every retry, keeps always).

Video recording modes

Video recording modes: 'off' (never records), 'on' (every run, keeps always), 'retain-on-failure' (every run, keeps when run failed), 'retain-on-first-failure' (first run only, keeps if first run failed), 'retain-on-failure-and-retries' (every run, keeps when failed or retry), 'on-first-retry' (first retry only, keeps always), 'on-all-retries' (every retry, keeps always).

TestOptions.actionTimeout property

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

TestOptions.browserName property

The browserName option specifies the name of the browser that runs tests. It defaults to 'chromium'. Supported values are 'chromium', 'firefox', or 'webkit'. It is configured in the use section of playwright.config.ts.

TestOptions.bypassCSP property

The bypassCSP option toggles bypassing Content-Security-Policy. This is useful when CSP includes the production origin. It defaults to false. It is configured in the use section of playwright.config.ts.

TestOptions.channel property

The channel option specifies the browser channel to use, for example 'chrome', 'chrome-beta', 'msedge', or 'msedge-beta'. It is configured in the use section of playwright.config.ts.

TestOptions.headless property

The headless option determines whether to run the browser in headless mode, meaning no browser is shown when running tests. It defaults to true. It is configured in the use section of playwright.config.ts.

TestOptions.testIdAttribute property

The testIdAttribute option changes the default data-testid attribute used by Playwright locators. It is configured in the use section of playwright.config.ts.

launchOptions, contextOptions, and connectOptions in use section

Any options accepted by BrowserType.launch(), Browser.newContext(), or BrowserType.connect() can be put into launchOptions, contextOptions, or connectOptions respectively in the use section of the Playwright config. However, most common options like headless or viewport are available directly in the use section.

Give your agent this brain