Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 🎭 Playwright

[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-145.0.7632.6-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-146.0.1-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-26.0-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop --> [![Join Discord](https://img.shields.io/badge/join-discord-informational)](https://aka.ms/playwright/discord)
[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-145.0.7632.18-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-146.0.1-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-26.0-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop --> [![Join Discord](https://img.shields.io/badge/join-discord-informational)](https://aka.ms/playwright/discord)

## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)

Playwright is a framework for Web Testing and Automation. It allows testing [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable**, and **fast**.

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->145.0.7632.6<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->145.0.7632.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->146.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Expand Down
40 changes: 40 additions & 0 deletions docs/src/api/class-browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,46 @@ Returns storage state for this browser context, contains current cookies, local
Set to `true` to include [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) in the storage state snapshot.
If your application uses IndexedDB to store authentication tokens, like Firebase Authentication, enable this.

## async method: BrowserContext.setStorageState
* since: v1.59

Clears the existing cookies, local storage and IndexedDB entries for all origins and sets the new storage state.

**Usage**

```js
// Load storage state from a file and apply it to the context.
await context.setStorageState('state.json');
```

```java
// Load storage state from a file and apply it to the context.
context.setStorageState(Paths.get("state.json"));
```

```python async
# Load storage state from a file and apply it to the context.
await context.set_storage_state("state.json")
```

```python sync
# Load storage state from a file and apply it to the context.
context.set_storage_state("state.json")
```

```csharp
// Load storage state from a file and apply it to the context.
await context.SetStorageStateAsync("state.json");
```

### param: BrowserContext.setStorageState.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.59
* langs: js, python

### param: BrowserContext.setStorageState.storageState = %%-csharp-java-context-option-storage-state-path-%%
* since: v1.59
* langs: csharp, java

## property: BrowserContext.tracing
* since: v1.12
- type: <[Tracing]>
Expand Down
3 changes: 3 additions & 0 deletions docs/src/api/class-electron.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ Maximum time in milliseconds to wait for the application to start. Defaults to `

### option: Electron.launch.tracesDir = %%-browser-option-tracesdir-%%
* since: v1.36

### option: Electron.launch.chromiumSandbox = %%-browser-option-chromiumsandbox-%%
* since: v1.59
5 changes: 3 additions & 2 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -4365,9 +4365,10 @@ Optional handler function to route the request.

## method: Page.video
* since: v1.8
- returns: <[null]|[Video]>
- returns: <[Video]>

Video object associated with this page.
Video object associated with this page. Can be used to control video recording with [`method: Video.start`]
and [`method: Video.stop`], or to access the video file when using the `recordVideo` context option.

## method: Page.viewportSize
* since: v1.8
Expand Down
89 changes: 89 additions & 0 deletions docs/src/api/class-video.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ print(page.video.path())
Console.WriteLine(await page.Video.GetPathAsync());
```

Alternatively, you can use [`method: Video.start`] and [`method: Video.stop`] to record video manually. This approach is mutually exclusive with the `recordVideo` option.

```js
await page.video().start();
// ... perform actions ...
await page.video().stop({ path: 'video.webm' });
```

```java
page.video().start();
// ... perform actions ...
page.video().stop(new Video.StopOptions().setPath(Paths.get("video.webm")));
```

```python async
await page.video.start()
# ... perform actions ...
await page.video.stop(path="video.webm")
```

```python sync
page.video.start()
# ... perform actions ...
page.video.stop(path="video.webm")
```

```csharp
await page.Video.StartAsync();
// ... perform actions ...
await page.Video.StopAsync(new() { Path = "video.webm" });
```

## async method: Video.delete
* since: v1.11

Expand Down Expand Up @@ -58,3 +90,60 @@ Saves the video to a user-specified path. If using the sync API, this must be ca
- `path` <[path]>

Path where the video should be saved.


## async method: Video.start
* since: v1.59

Starts video recording. This method is mutually exclusive with the `recordVideo` context option.

**Usage**

```js
await page.video().start();
// ... perform actions ...
await page.video().stop({ path: 'video.webm' });
```

```java
page.video().start();
// ... perform actions ...
page.video().stop(new Video.StopOptions().setPath(Paths.get("video.webm")));
```

```python async
await page.video.start()
# ... perform actions ...
await page.video.stop(path="video.webm")
```

```python sync
page.video.start()
# ... perform actions ...
page.video.stop(path="video.webm")
```

```csharp
await page.Video.StartAsync();
// ... perform actions ...
await page.Video.StopAsync(new() { Path = "video.webm" });
```

### option: Video.start.size
* since: v1.59
- `size` ?<[Object]>
- `width` <[int]> Video frame width.
- `height` <[int]> Video frame height.

Optional dimensions of the recorded video. If not specified the size will be equal to page viewport scaled down to fit into 800x800. Actual picture of the page will be scaled down if necessary to fit the specified size.

## async method: Video.stop
* since: v1.59

Stops video recording started with [`method: Video.start`] and either saves or discards the video file.

### option: Video.stop.path
* since: v1.59
- `path` <[path]>

Path where the video should be saved.
3 changes: 2 additions & 1 deletion examples/todomvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.38.0"
"@playwright/test": "^1.38.0",
"dotenv": "^17.2.3"
}
}
2 changes: 1 addition & 1 deletion examples/todomvc/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';

dotenv.config();
dotenv.config({ quiet: true });

/**
* See https://playwright.dev/docs/test-configuration.
Expand Down
131 changes: 129 additions & 2 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4802,9 +4802,12 @@ export interface Page {
url(): string;

/**
* Video object associated with this page.
* Video object associated with this page. Can be used to control video recording with
* [video.start([options])](https://playwright.dev/docs/api/class-video#video-start) and
* [video.stop([options])](https://playwright.dev/docs/api/class-video#video-stop), or to access the video file when
* using the `recordVideo` context option.
*/
video(): null|Video;
video(): Video;

viewportSize(): null|{
/**
Expand Down Expand Up @@ -9611,6 +9614,71 @@ export interface BrowserContext {
*/
setOffline(offline: boolean): Promise<void>;

/**
* Clears the existing cookies, local storage and IndexedDB entries for all origins and sets the new storage state.
*
* **Usage**
*
* ```js
* // Load storage state from a file and apply it to the context.
* await context.setStorageState('state.json');
* ```
*
* @param storageState Learn more about [storage state and auth](https://playwright.dev/docs/auth).
*
* Populates context with given storage state. This option can be used to initialize context with logged-in
* information obtained via
* [browserContext.storageState([options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-storage-state).
*/
setStorageState(storageState: string|{
/**
* Cookies to set for context
*/
cookies: Array<{
name: string;

value: string;

/**
* Domain and path are required. For the cookie to apply to all subdomains as well, prefix domain with a dot, like
* this: ".example.com"
*/
domain: string;

/**
* Domain and path are required
*/
path: string;

/**
* Unix time in seconds.
*/
expires: number;

httpOnly: boolean;

secure: boolean;

/**
* sameSite flag
*/
sameSite: "Strict"|"Lax"|"None";
}>;

origins: Array<{
origin: string;

/**
* localStorage to set for context
*/
localStorage: Array<{
name: string;

value: string;
}>;
}>;
}): Promise<void>;

/**
* Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB
* snapshot.
Expand Down Expand Up @@ -19566,6 +19634,11 @@ export interface Electron {
*/
bypassCSP?: boolean;

/**
* Enable Chromium sandboxing. Defaults to `false`.
*/
chromiumSandbox?: boolean;

/**
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
* media feature, supported values are `'light'` and `'dark'`. See
Expand Down Expand Up @@ -21757,6 +21830,16 @@ export interface Tracing {
* console.log(await page.video().path());
* ```
*
* Alternatively, you can use [video.start([options])](https://playwright.dev/docs/api/class-video#video-start) and
* [video.stop([options])](https://playwright.dev/docs/api/class-video#video-stop) to record video manually. This
* approach is mutually exclusive with the `recordVideo` option.
*
* ```js
* await page.video().start();
* // ... perform actions ...
* await page.video().stop({ path: 'video.webm' });
* ```
*
*/
export interface Video {
/**
Expand All @@ -21776,6 +21859,50 @@ export interface Video {
* @param path Path where the video should be saved.
*/
saveAs(path: string): Promise<void>;

/**
* Starts video recording. This method is mutually exclusive with the `recordVideo` context option.
*
* **Usage**
*
* ```js
* await page.video().start();
* // ... perform actions ...
* await page.video().stop({ path: 'video.webm' });
* ```
*
* @param options
*/
start(options?: {
/**
* Optional dimensions of the recorded video. If not specified the size will be equal to page viewport scaled down to
* fit into 800x800. Actual picture of the page will be scaled down if necessary to fit the specified size.
*/
size?: {
/**
* Video frame width.
*/
width: number;

/**
* Video frame height.
*/
height: number;
};
}): Promise<void>;

/**
* Stops video recording started with
* [video.start([options])](https://playwright.dev/docs/api/class-video#video-start) and either saves or discards the
* video file.
* @param options
*/
stop(options?: {
/**
* Path where the video should be saved.
*/
path?: string;
}): Promise<void>;
}

/**
Expand Down
Loading
Loading