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
Expand Up @@ -3,9 +3,9 @@

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->134.0.6998.35<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->136.0.7103.25<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->135.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->137.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |

Playwright for .NET is the official language port of [Playwright](https://playwright.dev), the library to automate [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**.

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyVersion>1.51.0</AssemblyVersion>
<PackageVersion>$(AssemblyVersion)</PackageVersion>
<DriverVersion>1.51.1</DriverVersion>
<DriverVersion>1.53.0-alpha-1744741041000</DriverVersion>
<ReleaseVersion>$(AssemblyVersion)</ReleaseVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<NoDefaultExcludes>true</NoDefaultExcludes>
Expand Down
46 changes: 23 additions & 23 deletions src/Playwright.TestingHarnessTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Playwright.TestingHarnessTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "playwright.testingharnesstest",
"private": true,
"devDependencies": {
"@playwright/test": "1.51.0-beta-1741166263000",
"@playwright/test": "1.53.0-alpha-1744741041000",
"@types/node": "^22.12.0",
"fast-xml-parser": "^4.5.0"
}
Expand Down
25 changes: 25 additions & 0 deletions src/Playwright.Tests/Assertions/LocatorAssertionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,31 @@ public async Task ShouldSupportToHaveClass()
}
}

[PlaywrightTest("playwright-test/playwright.expect.spec.ts", "should support toContainClass")]
public async Task ShouldSupportToContainClass()
{
{
await Page.SetContentAsync("<div class=\"foo bar baz\"></div>");
var locator = Page.Locator("div");
await Expect(locator).ToContainClassAsync("");
await Expect(locator).ToContainClassAsync("bar");
await Expect(locator).ToContainClassAsync("baz bar");
await Expect(locator).ToContainClassAsync(" bar foo ");
await Expect(locator).Not.ToContainClassAsync("baz not-matching");
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => Expect(locator).ToContainClassAsync("does-not-exist", new() { Timeout = 300 }));
StringAssert.Contains("Locator expected to contain class names 'does-not-exist'", exception.Message);
StringAssert.Contains("But was: 'foo bar baz'", exception.Message);
StringAssert.Contains("LocatorAssertions.ToContainClassAsync with timeout 300ms", exception.Message);
}
{
await Page.SetContentAsync("<div class=\"foo\"></div><div class=\"hello bar\"></div><div class=\"baz\"></div>");
var locator = Page.Locator("div");
await Expect(locator).ToContainClassAsync(new string[] { "foo", "hello", "baz" });
await Expect(locator).Not.ToContainClassAsync(new string[] { "not-there", "hello", "baz" });
await Expect(locator).Not.ToContainClassAsync(new string[] { "foo", "hello" });
}
}

[PlaywrightTest("playwright-test/playwright.expect.spec.ts", "should support toHaveCount")]
public async Task ShouldSupportToHaveCount()
{
Expand Down
16 changes: 16 additions & 0 deletions src/Playwright.Tests/GlobalFetchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,22 @@ public async Task ShouldNotFollowRedirectsWhenMaxRedirectsIsSetTo0()
await request.DisposeAsync();
}

[PlaywrightTest("global-fetch.spec.ts", "should not follow redirects when maxRedirects is set to 0 in newContext")]
public async Task ShouldNotFollowRedirectsWhenMaxRedirectsIsSetTo0InNewContext()
{
Server.SetRedirect("/a/redirect1", "/b/c/redirect2");
Server.SetRedirect("/b/c/redirect2", "/simple.json");

var request = await Playwright.APIRequest.NewContextAsync(new() { MaxRedirects = 0 });
foreach (var method in new[] { "GET", "PUT", "POST", "OPTIONS", "HEAD", "PATCH" })
{
var response = await request.FetchAsync($"{Server.Prefix}/a/redirect1", new() { Method = method });
Assert.AreEqual("/b/c/redirect2", response.Headers["location"]);
Assert.AreEqual(302, response.Status);
}
await request.DisposeAsync();
}

[PlaywrightTest("global-fetch.spec.ts", "should throw an error when maxRedirects is less than 0")]
public async Task ShouldThrowAnErrorWhenMaxRedirectsIsLessThan0()
{
Expand Down
59 changes: 58 additions & 1 deletion src/Playwright.Tests/PageAriaSnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,64 @@ await Page.SetContentAsync(@"
await CheckAndMatchSnapshot(Page.Locator("body"), @"
- list:
- listitem:
- link ""link""
- link ""link"":
- /url: about:blank
");
}

[PlaywrightTest("to-match-aria-snapshot.spec.ts", "should detect unexpected children: equal")]
public async Task ShouldDetectUnexpectedChildrenEqual()
{
await Page.SetContentAsync(@"
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
");
await Expect(Page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- list:
- listitem: ""One""
- listitem: ""Three""
");
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() =>
{
return Expect(Page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- list:
- /children: equal
- listitem: ""One""
- listitem: ""Three""
", new() { Timeout = 300 });
});
StringAssert.Contains("LocatorAssertions.ToMatchAriaSnapshotAsync with timeout 300ms", exception.Message);
StringAssert.Contains("- unexpected value", exception.Message);
}

[PlaywrightTest("page-aria-snapshot.spec.ts", "should generate refs")]
public async Task ShouldGenerateRefs()
{
await Page.SetContentAsync(@"
<button>One</button>
<button>Two</button>
<button>Three</button>
");
var snapshot = await Page.Locator("body").AriaSnapshotAsync(new() { Ref = true });
Assert.AreEqual(_unshift(@"
- button ""One"" [ref=s1e3]
- button ""Two"" [ref=s1e4]
- button ""Three"" [ref=s1e5]
"), snapshot);
}

[PlaywrightTest("to-match-aria-snapshot.spec.ts", "should match url")]
public async Task ShouldMatchUrl()
{
await Page.SetContentAsync(@"
<a href='https://example.com'>Link</a>
");
await Expect(Page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- link:
- /url: /.*example.com/
");
}
}
3 changes: 1 addition & 2 deletions src/Playwright.Tests/PageClockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ public async Task ShouldPause()
await Page.Clock.InstallAsync(new() { TimeDate = DateTimeOffset.FromUnixTimeMilliseconds(0).UtcDateTime });
await Page.GotoAsync("data:text/html,");
await Page.Clock.PauseAtAsync(DateTimeOffset.FromUnixTimeMilliseconds(1000).UtcDateTime);
await Page.WaitForTimeoutAsync(1000);
await Page.Clock.ResumeAsync();
await Page.WaitForTimeoutAsync(1111);
var now = await Page.EvaluateAsync<long>("Date.now()");
Assert.GreaterOrEqual(now, 0);
Assert.LessOrEqual(now, 1000);
Expand Down
16 changes: 16 additions & 0 deletions src/Playwright.Tests/PageEvaluateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ public async Task ShouldTransferNegativeInfinity()
Assert.AreEqual(double.NegativeInfinity, result);
}

[PlaywrightTest("page-evaluate.spec.ts", "should transfer typed arrays")]
public async Task ShouldTransferTypedArrays()
{
Assert.AreEqual(new sbyte[] { 1, 2, 3 }, await Page.EvaluateAsync<sbyte[]>("() => new Int8Array([1, 2, 3])"));
Assert.AreEqual(new byte[] { 1, 2, 3 }, await Page.EvaluateAsync<byte[]>("() => new Uint8Array([1, 2, 3])"));
Assert.AreEqual(new byte[] { 1, 2, 3 }, await Page.EvaluateAsync<byte[]>("() => new Uint8ClampedArray([1, 2, 3])"));
Assert.AreEqual(new short[] { 1, 2, 3 }, await Page.EvaluateAsync<short[]>("() => new Int16Array([1, 2, 3])"));
Assert.AreEqual(new ushort[] { 1, 2, 3 }, await Page.EvaluateAsync<ushort[]>("() => new Uint16Array([1, 2, 3])"));
Assert.AreEqual(new int[] { 1, 2, 3 }, await Page.EvaluateAsync<int[]>("() => new Int32Array([1, 2, 3])"));
Assert.AreEqual(new uint[] { 1, 2, 3 }, await Page.EvaluateAsync<uint[]>("() => new Uint32Array([1, 2, 3])"));
Assert.AreEqual(new float[] { 1.5F, 2.5F, 3.5F }, await Page.EvaluateAsync<float[]>("() => new Float32Array([1.5, 2.5, 3.5])"));
Assert.AreEqual(new double[] { 1.5, 2.5, 3.5 }, await Page.EvaluateAsync<double[]>("() => new Float64Array([1.5, 2.5, 3.5])"));
Assert.AreEqual(new long[] { 1, 2, 3 }, await Page.EvaluateAsync<long[]>("() => new BigInt64Array([1n, 2n, 3n])"));
Assert.AreEqual(new ulong[] { 1, 2, 3 }, await Page.EvaluateAsync<ulong[]>("() => new BigUint64Array([1n, 2n, 3n])"));
}

[PlaywrightTest("page-evaluate.spec.ts", "should transfer bigint")]
public async Task ShouldTransferBigInt()
{
Expand Down
13 changes: 7 additions & 6 deletions src/Playwright.Tests/PageRouteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ void handler4(IRoute route)
Assert.AreEqual(new[] { 1 }, intercepted.ToArray());
}

[PlaywrightTest("page-route.spec.ts", "should support ? in glob pattern")]
public async Task ShouldSupportInGlobPattern()
[PlaywrightTest("page-route.spec.ts", "should not support ? in glob pattern")]
public async Task ShouldNotSupportQuestionMarkInGlobPattern()
{
Server.SetRoute("/index", context => context.Response.WriteAsync("index-no-hello"));
Server.SetRoute("/index123hello", context => context.Response.WriteAsync("index123hello"));
Server.SetRoute("/index?hello", context => context.Response.WriteAsync("index?hello"));
Server.SetRoute("/index1hello", context => context.Response.WriteAsync("index1hello"));

await Page.RouteAsync("**/index?hello", (route) => route.FulfillAsync(new() { Body = "intercepted any character" }));
await Page.RouteAsync("**/index\\?hello", (route) => route.FulfillAsync(new() { Body = "intercepted question mark" }));
Expand All @@ -116,7 +117,7 @@ public async Task ShouldSupportInGlobPattern()
StringAssert.Contains("index-no-hello", await Page.ContentAsync());

await Page.GotoAsync(Server.Prefix + "/index1hello");
StringAssert.Contains("intercepted any character", await Page.ContentAsync());
StringAssert.Contains("index1hello", await Page.ContentAsync());

await Page.GotoAsync(Server.Prefix + "/index123hello");
StringAssert.Contains("index123hello", await Page.ContentAsync());
Expand Down Expand Up @@ -642,7 +643,7 @@ await Page.RouteAsync("**/cars*", (route) =>
method: 'POST',
headers: { 'Content-Type': 'application/json' },
mode: 'cors',
body: JSON.stringify({ 'number': 1 })
body: JSON.stringify({ 'number': 1 })
});
return response.json();
}");
Expand Down Expand Up @@ -670,7 +671,7 @@ await Page.RouteAsync("**/cars*", (route) =>
method: 'POST',
headers: { 'Content-Type': 'application/json' },
mode: 'cors',
body: JSON.stringify({ 'number': 1 })
body: JSON.stringify({ 'number': 1 })
});
return response.json();
}");
Expand All @@ -682,7 +683,7 @@ await Page.RouteAsync("**/cars*", (route) =>
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
mode: 'cors',
body: JSON.stringify({ 'number': 1 })
body: JSON.stringify({ 'number': 1 })
});
return response.json();
}");
Expand Down
Loading