v1.40.0
Test Generator Update
New tools to generate assertions:
- "Assert visibility" tool generates Expect(locator).ToBeVisibleAsync([options]).
- "Assert value" tool generates Expect(locator).ToHaveValueAsync(value[, options]).
- "Assert text" tool generates Expect(locator).ToContainTextAsync(expected).
Here is an example of a generated test with assertions:
await Page.GotoAsync("https://playwright.dev/");
await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();
await Expect(Page.GetByLabel("Breadcrumbs").GetByRole(AriaRole.List)).ToContainTextAsync("Installation");
await Expect(Page.GetByLabel("Search")).ToBeVisibleAsync();
await Page.GetByLabel("Search").ClickAsync();
await Page.GetByPlaceholder("Search docs").FillAsync("locator");
await Expect(Page.GetByPlaceholder("Search docs")).ToHaveValueAsync("locator");
New APIs
- Option
Reason
in Page.CloseAsync([options]), BrowserContext.CloseAsync([options]) and Browser.CloseAsync([options]). Close reason is reported for all operations interrupted by the closure. - Option
FirefoxUserPrefs
in browserType.launchPersistentContext(userDataDir[, options]).
Other Changes
- Methods download.PathAsync() throw an error for failed and cancelled downloads.
- Playwright docker image now comes with .NET 8 (new LTS).
Potential breaking changes
When using Microsoft.Playwright.MSTest
or Microsoft.Playwright.NUnit
, Locale
and ColorScheme
were taken from the operating system as a default. After v1.40, its now aligned with Playwright for Node.js to en-US
and light
. In order to opt-in for the previous behaviour, the ContextOptions
method can be overidden.
using Microsoft.Playwright.NUnit;
namespace PlaywrightTests;
[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class MyTest : PageTest
{
public override BrowserNewContextOptions ContextOptions()
{
return new BrowserNewContextOptions()
{
Locale = "en-GB",
ColorScheme = ColorScheme.Light,
};
}
}
Browser Versions
- Chromium 120.0.6099.28
- Mozilla Firefox 119.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 119
- Microsoft Edge 119