Skip to content

Releases: microsoft/playwright-dotnet

v1.49.0

21 Nov 23:29
d7922c6
Compare
Choose a tag to compare

Aria snapshots

New assertion Expect(locator).toMatchAriaSnapshot() verifies page structure by comparing to an expected accessibility tree, represented as YAML.

await page.GotoAsync("https://playwright.dev");
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"
  - banner:
    - heading /Playwright enables reliable/ [level=1]
    - link ""Get started""
    - link ""Star microsoft/playwright on GitHub""
  - main:
    - img ""Browsers (Chromium, Firefox, WebKit)""
    - heading ""Any browser • Any platform • One API""
");

You can generate this assertion with Test Generator or by calling locator.ariaSnapshot().

Learn more in the aria snapshots guide.

Tracing groups

New method tracing.group() allows you to visually group actions in the trace viewer.

// All actions between GroupAsync and GroupEndAsync
// will be shown in the trace viewer as a group.
await Page.Context.Tracing.GroupAsync("Open Playwright.dev > API");
await Page.GotoAsync("https://playwright.dev/");
await Page.GetByRole(AriaRole.Link, new() { Name = "API" }).ClickAsync();
await Page.Context.Tracing.GroupEndAsync();

Breaking: chrome and msedge channels switch to new headless mode

This change affects you if you're using one of the following channels in your playwright.config.ts:

  • chrome, chrome-dev, chrome-beta, or chrome-canary
  • msedge, msedge-dev, msedge-beta, or msedge-canary

After updating to Playwright v1.49, run your test suite. If it still passes, you're good to go. If not, you will probably need to update your snapshots, and adapt some of your test code around PDF viewers and extensions. See issue #33566 for more details.

Try new Chromium headless

You can opt into the new headless mode by using 'chromium' channel. As official Chrome documentation puts it:

New Headless on the other hand is the real Chrome browser, and is thus more authentic, reliable, and offers more features. This makes it more suitable for high-accuracy end-to-end web app testing or browser extension testing.

See issue #33566 for the list of possible breakages you could encounter and more details on Chromium headless. Please file an issue if you see any problems after opting in.

// runsettings.xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <Playwright>
    <BrowserName>chromium</BrowserName>
    <LaunchOptions>
      <Channel>chromium</Channel>
    </LaunchOptions>
  </Playwright>
</RunSettings>
dotnet test -- Playwright.BrowserName=chromium Playwright.LaunchOptions.Channel=chromium

Miscellaneous

  • There will be no more updates for WebKit on Ubuntu 20.04 and Debian 11. We recommend updating your OS to a later version.
  • <canvas> elements inside a snapshot now draw a preview.

Browser Versions

  • Chromium 131.0.6778.33
  • Mozilla Firefox 132.0
  • WebKit 18.2

This version was also tested against the following stable channels:

  • Google Chrome 130
  • Microsoft Edge 130

v1.48.0

21 Oct 23:00
57426b2
Compare
Choose a tag to compare

WebSocket routing

New methods Page.RouteWebSocketAsync() and BrowserContext.RouteWebSocketAsync() allow to intercept, modify and mock WebSocket connections initiated in the page. Below is a simple example that mocks WebSocket communication by responding to a "request" with a "response".

await page.RouteWebSocketAsync("/ws", ws => {
  ws.OnMessage(message => {
    if (message.Text == "request")
      ws.Send("response");
  });
});

See WebSocketRoute for more details.

UI updates

  • New "copy" buttons for annotations and test location in the HTML report.
  • Route method calls like Foute.FulfillAsync() are not shown in the report and trace viewer anymore. You can see which network requests were routed in the network tab instead.
  • New "Copy as cURL" and "Copy as fetch" buttons for requests in the network tab.

Miscellaneous

Browser Versions

  • Chromium 130.0.6723.19
  • Mozilla Firefox 130.0
  • WebKit 18.0

This version was also tested against the following stable channels:

  • Google Chrome 129
  • Microsoft Edge 129

v1.47.0

12 Sep 17:31
ce4981b
Compare
Choose a tag to compare

Network Tab improvements

The Network tab in the trace viewer has several nice improvements:

  • filtering by asset type and URL
  • better display of query string parameters
  • preview of font assets

Network tab now has filters

Miscellaneous

  • The mcr.microsoft.com/playwright/dotnet:v1.47.0 now serves a Playwright image based on Ubuntu 24.04 Noble.
    To use the 22.04 jammy-based image, please use mcr.microsoft.com/playwright/dotnet:v1.47.0-jammy instead.
  • The :latest/:focal/:jammy tag for Playwright Docker images is no longer being published. Pin to a specific version for better stability and reproducibility.
  • TLS client certificates can now be passed from memory by passing cert and key as byte arrays instead of file paths.
  • NoWaitAfter in locator.selectOption() was deprecated.
  • We've seen reports of WebGL in Webkit misbehaving on GitHub Actions macos-13. We recommend upgrading GitHub Actions to macos-14.

Browser Versions

  • Chromium 129.0.6668.29
  • Mozilla Firefox 130.0
  • WebKit 18.0

This version was also tested against the following stable channels:

  • Google Chrome 128
  • Microsoft Edge 128

v1.46.0

12 Aug 13:10
f8f6209
Compare
Choose a tag to compare

TLS Client Certificates

Playwright now allows to supply client-side certificates, so that server can verify them, as specified by TLS Client Authentication.

You can provide client certificates as a parameter of browser.NewContextAsync() and APIRequest.NewContextAsync(). The following snippet sets up a client certificate for https://example.com:

var context = await Browser.NewContextAsync(new() {
  ClientCertificates = [
    new() {
      Origin = "https://example.com",
      CertPath = "client-certificates/cert.pem",
      KeyPath = "client-certificates/key.pem",
    }
  ]
});

When using the MSTest or NUnit base-classes, these can be added by using the ContextOptions method.

Trace Viewer Updates

  • Content of text attachments is now rendered inline in the attachments pane.
  • New setting to show/hide routing actions like route.ContinueAsync().
  • Request method and status are shown in the network details tab.
  • New button to copy source file location to clipboard.
  • Metadata pane now displays the BaseURL.

Miscellaneous

Browser Versions

  • Chromium 128.0.6613.18
  • Mozilla Firefox 128.0
  • WebKit 18.0

This version was also tested against the following stable channels:

  • Google Chrome 127
  • Microsoft Edge 127

v1.45.1

23 Jul 11:09
0902fe0
Compare
Choose a tag to compare

Highlights

microsoft/playwright-java#1617 - [Bug]: Trace Viewer not reporting all actions
microsoft/playwright#31764 - [Bug]: some actions do not appear in the trace file

Browser Versions

  • Chromium 127.0.6533.5
  • Mozilla Firefox 127.0
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 126
  • Microsoft Edge 126

v1.45.0

04 Jul 11:36
c4b3dc4
Compare
Choose a tag to compare

Clock

Utilizing the new Clock API allows to manipulate and control time within tests to verify time-related behavior. This API covers many common scenarios, including:

  • testing with predefined time;
  • keeping consistent time and timers;
  • monitoring inactivity;
  • ticking through time manually.
// Initialize clock with some time before the test time and let the page load naturally.
// `Date.now` will progress as the timers fire.
await Page.Clock.InstallAsync(new()
{
  TimeDate = new DateTime(2024, 2, 2, 8, 0, 0)
});
await Page.GotoAsync("http://localhost:3333");

// Pretend that the user closed the laptop lid and opened it again at 10am.
// Pause the time once reached that point.
await Page.Clock.PauseAtAsync(new DateTime(2024, 2, 2, 10, 0, 0));

// Assert the page state.
await Expect(Page.GetByTestId("current-time")).ToHaveTextAsync("2/2/2024, 10:00:00 AM");

// Close the laptop lid again and open it at 10:30am.
await Page.Clock.FastForwardAsync("30:00");
await Expect(Page.GetByTestId("current-time")).ToHaveTextAsync("2/2/2024, 10:30:00 AM");

See the clock guide for more details.

Miscellaneous

  • Method locator.setInputFiles() now supports uploading a directory for <input type=file webkitdirectory> elements.
    await page.GetByLabel("Upload directory").SetInputFilesAsync("mydir");
  • Multiple methods like locator.click() or locator.press() now support a ControlOrMeta modifier key. This key maps to Meta on macOS and maps to Control on Windows and Linux.
    // Press the common keyboard shortcut Control+S or Meta+S to trigger a "Save" operation.
    await page.Keyboard.PressAsync("ControlOrMeta+S");
  • New property httpCredentials.send in apiRequest.newContext() that allows to either always send the Authorization header or only send it in response to 401 Unauthorized.
  • Playwright now supports Chromium, Firefox and WebKit on Ubuntu 24.04.
  • v1.45 is the last release to receive WebKit update for macOS 12 Monterey. Please update macOS to keep using the latest WebKit.

Browser Versions

  • Chromium 127.0.6533.5
  • Mozilla Firefox 127.0
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 126
  • Microsoft Edge 126

v1.44.0

17 May 10:06
Compare
Choose a tag to compare

New APIs

Accessibility assertions

  • Expect(locator).ToHaveAccessibleNameAsync() checks if the element has the specified accessible name:

    var locator = Page.GetByRole(AriaRole.Button);
    await Expect(locator).ToHaveAccessibleNameAsync("Submit");
  • Expect(locator).ToHaveAccessibleDescriptionAsync() checks if the element has the specified accessible description:

    var locator = Page.GetByRole(AriaRole.Button);
    await Expect(locator).ToHaveAccessibleDescriptionAsync("Upload a photo");
  • Expect(locator).ToHaveRoleAsync() checks if the element has the specified ARIA role:

    var locator = Page.GetByTestId("save-button");
    await Expect(locator).ToHaveRoleAsync(AriaRole.Button);

Locator handler

var locator = Page.GetByText("This interstitial covers the button");
await Page.AddLocatorHandlerAsync(locator, async (overlay) =>
{
    await overlay.Locator("#close").ClickAsync();
}, new() { Times = 3, NoWaitAfter = true });
// Run your tests that can be interrupted by the overlay.
// ...
await Page.RemoveLocatorHandlerAsync(locator);

Miscellaneous options

  • Multipart option in APIRequestContext.FetchAsync() supports now repeating fields with the same name using formData.append():

    var formData = Context.APIRequest.CreateFormData();
    formData.Append("file", new FilePayload()
    {
        Name = "f1.js",
        MimeType = "text/javascript",
        Buffer = System.Text.Encoding.UTF8.GetBytes("var x = 2024;")
    });
    formData.Append("file", new FilePayload()
    {
        Name = "f2.txt",
        MimeType = "text/plain",
        Buffer = System.Text.Encoding.UTF8.GetBytes("hello")
    });
    var response = await Context.APIRequest.PostAsync("https://example.com/uploadFiles", new() { Multipart = formData });
  • Expect(page).ToHaveURLAsync() now supports IgnoreCase option.

Browser Versions

  • Chromium 125.0.6422.14
  • Mozilla Firefox 125.0.1
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 124
  • Microsoft Edge 124

v1.43.0

09 Apr 19:34
98e3755
Compare
Choose a tag to compare

New APIs

  • Method BrowserContext.ClearCookiesAsync() now supports filters to remove only some cookies.

    // Clear all cookies.
    await Context.ClearCookiesAsync();
    // New: clear cookies with a particular name.
    await Context.ClearCookiesAsync(new() { Name = "session-id" });
    // New: clear cookies for a particular domain.
    await Context.ClearCookiesAsync(new() { Domain = "my-origin.com" });
  • New property Locator.ContentFrame converts a Locator object to a FrameLocator. This can be useful when you have a Locator object obtained somewhere, and later on would like to interact with the content inside the frame.

    var locator = Page.Locator("iframe[name='embedded']");
    // ...
    var frameLocator = locator.ContentFrame;
    await frameLocator.GetByRole(AriaRole.Button).ClickAsync();
  • New property FrameLocator.Owner converts a FrameLocator object to a Locator. This can be useful when you have a FrameLocator object obtained somewhere, and later on would like to interact with the iframe element.

    var frameLocator = page.FrameLocator("iframe[name='embedded']");
    // ...
    var locator = frameLocator.Owner;
    await Expect(locator).ToBeVisibleAsync();

Browser Versions

  • Chromium 124.0.6367.8
  • Mozilla Firefox 124.0
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 123
  • Microsoft Edge 123

v1.42.0

07 Mar 16:39
913fbd3
Compare
Choose a tag to compare

New Locator Handler

New method page.addLocatorHandler(locator, handler, handler, handler) registers a callback that will be invoked when specified element becomes visible and may block Playwright actions. The callback can get rid of the overlay. Here is an example that closes a cookie dialog when it appears.

// Setup the handler.
await Page.AddLocatorHandlerAsync(
    Page.GetByRole(AriaRole.Heading, new() { Name = "Hej! You are in control of your cookies." }),
    async () =>
    {
        await Page.GetByRole(AriaRole.Button, new() { Name = "Accept all" }).ClickAsync();
    });
// Write the test as usual.
await Page.GotoAsync("https://www.ikea.com/");
await Page.GetByRole(AriaRole.Link, new() { Name = "Collection of blue and white" }).ClickAsync();
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Light and easy" })).ToBeVisibleAsync();

New APIs

Announcements

  • ⚠️ Ubuntu 18 is not supported anymore.

Browser Versions

  • Chromium 123.0.6312.4
  • Mozilla Firefox 123.0
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 122
  • Microsoft Edge 123

v1.41.2

24 Jan 23:08
ef31243
Compare
Choose a tag to compare

Highlights

microsoft/playwright#29067 - [REGRESSION] Codegen/Recorder: not all clicks are being actioned nor recorded
microsoft/playwright#29019 - [REGRESSION] trace.playwright.dev does not currently support the loading from URL

Browser Versions

  • Chromium 121.0.6167.57
  • Mozilla Firefox 121.0
  • WebKit 17.4

This version was also tested against the following stable channels:

  • Google Chrome 120
  • Microsoft Edge 120