Skip to content
Open
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 docs/src/api/class-formdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Field name.

### param: FormData.append.value
* since: v1.44
- `value` <[string]|[boolean]|[int]|[Path]|[Object]>
- `value` <[string]|[boolean]|[int]|[path]|[Object]>
- alias: FilePayload
- `name` <[string]> File name
- `mimeType` <[string]> File type
Expand Down Expand Up @@ -215,7 +215,7 @@ Field name.

### param: FormData.set.value
* since: v1.18
- `value` <[string]|[boolean]|[int]|[Path]|[Object]>
- `value` <[string]|[boolean]|[int]|[path]|[Object]>
- alias: FilePayload
- `name` <[string]> File name
- `mimeType` <[string]> File type
Expand Down
167 changes: 62 additions & 105 deletions docs/src/electron-api/class-electron.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
* since: v1.9
* langs: js

Playwright has **experimental** support for Electron automation, exposed as `_electron`. An example of the Electron automation script would be:
Playwright has **experimental** support for Electron automation. You can access electron namespace via:

```js
import { _electron as electron } from 'playwright';
const { _electron } = require('playwright');
```

An example of the Electron automation script would be:

```js
const { _electron: electron } = require('playwright');

(async () => {
// Launch Electron app.
Expand Down Expand Up @@ -45,109 +51,6 @@ If you are not able to launch Electron and it will end up in timeouts during lau

* Ensure that `nodeCliInspect` ([FuseV1Options.EnableNodeCliInspectArguments](https://www.electronjs.org/docs/latest/tutorial/fuses#nodecliinspect)) fuse is **not** set to `false`.

**Migrating from v1.59**

A number of launch options have been removed after v1.59. See below for alternatives.

* `recordHar` - use [`method: Tracing.startHar`].
```js
const electronApp = await electron.launch({ args: ['main.js'] });
await electronApp.context().tracing.startHar('network.har');
// ... drive the app ...
await electronApp.context().tracing.stopHar();
await electronApp.close();
```

* `recordVideo` - use [`method: Screencast.start`] on each window.
```js
const electronApp = await electron.launch({ args: ['main.js'] });
const window = await electronApp.firstWindow();
await window.screencast.start({ path: 'video.webm' });
// ... drive the window ...
await window.screencast.stop();
await electronApp.close();
```

* `colorScheme` - use [`method: Page.emulateMedia`] on each window.
```js
const window = await electronApp.firstWindow();
await window.emulateMedia({ colorScheme: 'dark' });
```

* `extraHTTPHeaders` - use [`method: BrowserContext.setExtraHTTPHeaders`].
```js
await electronApp.context().setExtraHTTPHeaders({ 'X-My-Header': 'value' });
```

* `geolocation` - use [`method: BrowserContext.setGeolocation`].
```js
await electronApp.context().setGeolocation({ latitude: 48.858455, longitude: 2.294474 });
```

* `httpCredentials` - use [`method: BrowserContext.setHTTPCredentials`].
```js
await electronApp.context().setHTTPCredentials({ username: 'user', password: 'pass' });
```

* `offline` - use [`method: BrowserContext.setOffline`].
```js
await electronApp.context().setOffline(true);
```

* `bypassCSP` - disable CSP at the `BrowserWindow` level via Electron's [web preferences](https://www.electronjs.org/docs/latest/api/structures/web-preferences). Note that `webSecurity: false` also disables CORS and the Same-Origin Policy.

```js
const win = new BrowserWindow({
webPreferences: {
webSecurity: false,
},
});
```

* `ignoreHTTPSErrors`

There are several ways to relax HTTPS checks in Electron. Pick the one that matches the scope you need.

Per-window, allow mixed content through [web preferences](https://www.electronjs.org/docs/latest/api/structures/web-preferences):

```js
const win = new BrowserWindow({
webPreferences: {
allowRunningInsecureContent: true,
},
});
```

Process-wide, ignore certificate errors via Chromium command-line switches
(must run before the `ready` event):

```js
const { app } = require('electron');
app.commandLine.appendSwitch('ignore-certificate-errors');
// Optional: also ignore localhost certificate errors when testing on an IP.
app.commandLine.appendSwitch('allow-insecure-localhost', 'true');
```

Per-request, accept the certificate manually via the
[`certificate-error`](https://www.electronjs.org/docs/latest/api/app#event-certificate-error)
event:

```js
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
event.preventDefault();
callback(true);
});
```

* `timezoneId` - set an environment variable at the very top of the main file, before any other logic or Chromium windows are initialized.
```js
// main.js
process.env.TZ = 'Europe/London';

const { app } = require('electron');
// ... rest of your app logic
```

## async method: Electron.launch
* since: v1.9
- returns: <[ElectronApplication]>
Expand Down Expand Up @@ -186,5 +89,59 @@ Specifies environment variables that will be visible to Electron. Defaults to `p

Maximum time in milliseconds to wait for the application to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

### option: Electron.launch.acceptdownloads = %%-context-option-acceptdownloads-%%
* since: v1.12

### option: Electron.launch.bypassCSP = %%-context-option-bypasscsp-%%
* since: v1.12

### option: Electron.launch.colorScheme = %%-context-option-colorscheme-%%
* since: v1.12

### option: Electron.launch.extraHTTPHeaders = %%-context-option-extrahttpheaders-%%
* since: v1.12

### option: Electron.launch.geolocation = %%-context-option-geolocation-%%
* since: v1.12

### option: Electron.launch.httpcredentials = %%-context-option-httpcredentials-%%
* since: v1.12

### option: Electron.launch.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
* since: v1.12

### option: Electron.launch.locale = %%-context-option-locale-%%
* since: v1.12

### option: Electron.launch.offline = %%-context-option-offline-%%
* since: v1.12

### option: Electron.launch.recordhar = %%-context-option-recordhar-%%
* since: v1.12

### option: Electron.launch.recordharpath = %%-context-option-recordhar-path-%%
* since: v1.12

### option: Electron.launch.recordHarOmitContent = %%-context-option-recordhar-omit-content-%%
* since: v1.12

### option: Electron.launch.recordvideo = %%-context-option-recordvideo-%%
* since: v1.12

### option: Electron.launch.recordvideodir = %%-context-option-recordvideo-dir-%%
* since: v1.12

### option: Electron.launch.recordvideosize = %%-context-option-recordvideo-size-%%
* since: v1.12

### option: Electron.launch.timezoneId = %%-context-option-timezoneid-%%
* since: v1.12

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

### option: Electron.launch.artifactsDir = %%-browser-option-artifactsdir-%%
* since: v1.59

### option: Electron.launch.chromiumSandbox = %%-browser-option-chromiumsandbox-%%
* since: v1.59
12 changes: 1 addition & 11 deletions docs/src/electron-api/class-electronapplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ obtain the application instance. This instance you can control main electron pro
as well as work with Electron windows:

```js
import { _electron as electron } from 'playwright';
const { _electron: electron } = require('playwright');

(async () => {
// Launch Electron app.
Expand Down Expand Up @@ -85,16 +85,6 @@ Page to retrieve the window for.

Closes Electron application.

### option: ElectronApplication.close.timeout
* since: v1.60
- `timeout` <[float]>

Maximum time in milliseconds to wait for the Electron application to gracefully close before forcefully terminating it.
By default, [`method: ElectronApplication.close`] waits indefinitely for the application to exit, which can hang if the
app has `before-quit` handlers that prevent shutdown, leaky IPC handlers, or child processes that keep it alive. When
specified, the underlying process is force-killed (SIGKILL on POSIX, `taskkill /T /F` on Windows) if it does not exit
within the given timeout.

## method: ElectronApplication.context
* since: v1.9
- returns: <[BrowserContext]>
Expand Down
81 changes: 81 additions & 0 deletions docs/src/release-notes-csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,87 @@ toc_max_heading_level: 2

import LiteYouTube from '@site/src/components/LiteYouTube';

## Version 1.60

### 🌐 HAR recording on Tracing

[`method: Tracing.startHar`] / [`method: Tracing.stopHar`] expose HAR recording as a first-class tracing API, with the same `Content`, `Mode` and `UrlFilter` options as `RecordHar`:

```csharp
await context.Tracing.StartHarAsync("trace.har");
var page = await context.NewPageAsync();
await page.GotoAsync("https://playwright.dev");
await context.Tracing.StopHarAsync();
```

### 🪝 Drop API

New [`method: Locator.drop`] simulates an external drag-and-drop of files or clipboard-like data onto an element. Playwright dispatches `dragenter`, `dragover`, and `drop` with a synthetic [DataTransfer] in the page context — works cross-browser and is great for testing upload zones:

```csharp
await page.Locator("#dropzone").DropAsync(new() {
Files = new FilePayload() {
Name = "note.txt",
MimeType = "text/plain",
Buffer = Encoding.UTF8.GetBytes("hello"),
},
});

await page.Locator("#dropzone").DropAsync(new() {
Data = new Dictionary<string, string> {
["text/plain"] = "hello world",
["text/uri-list"] = "https://example.com",
},
});
```

### 🎯 Aria snapshots

- [`method: PageAssertions.toMatchAriaSnapshot`] now works on a [Page], in addition to a [Locator] — equivalent to asserting against `Page.Locator("body")`.
- New `Boxes` option on [`method: Locator.ariaSnapshot`] / [`method: Page.ariaSnapshot`] appends each element's bounding box as `[box=x,y,width,height]`, useful for AI consumption.

### New APIs

#### Browser, Context and Page

- Event [`event: Browser.context`] — fired when a new context is created on the browser.
- [BrowserContext] now mirrors lifecycle events from its pages: [`event: BrowserContext.download`], [`event: BrowserContext.frameAttached`], [`event: BrowserContext.frameDetached`], [`event: BrowserContext.frameNavigated`], [`event: BrowserContext.pageClose`], [`event: BrowserContext.pageLoad`].

#### Locators and Assertions

- New option `Description` in [`method: Page.getByRole`] / [`method: Locator.getByRole`] / [`method: Frame.getByRole`] / [`method: FrameLocator.getByRole`] for matching the [accessible description](https://www.w3.org/TR/wai-aria-1.2/#dfn-accessible-description).
- New option `Pseudo` in [`method: LocatorAssertions.toHaveCSS`] reads computed styles from `::before` or `::after`.
- New option `Style` in [`method: Locator.highlight`] applies extra inline CSS to the highlight overlay, plus new [`method: Page.hideHighlight`] to clear all highlights.

#### Network

- [`method: WebSocketRoute.protocols`] returns the WebSocket subprotocols requested by the page.
- New option `NoDefaults` in [`method: BrowserType.connectOverCDP`] disables Playwright's default overrides on the default context (download behavior, focus emulation, media emulation), so attaching to a user's daily-driver browser doesn't disturb its state.

#### Errors

- New [`method: WebError.location`] mirrors [`method: ConsoleMessage.location`].

### 🛠️ Other improvements

- Trace Viewer adds a pretty-print toggle for JSON / form request and response bodies in the network details panel.

### Breaking Changes ⚠️

- Removed long-deprecated `Handle` option on `BrowserContext.ExposeBindingAsync` and `Page.ExposeBindingAsync`.

### Browser Versions

- Chromium 148.0.7778.96
- Mozilla Firefox 150.0.2
- WebKit 26.4

This version was also tested against the following stable channels:

- Google Chrome 147
- Microsoft Edge 147


## Version 1.59

### 🎬 Screencast
Expand Down
Loading