Skip to content

Commit

Permalink
chore(roll): roll Playwright to v1.36.0 (#2634)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Jul 13, 2023
1 parent 2ee4c31 commit f545f6a
Show file tree
Hide file tree
Showing 22 changed files with 138 additions and 137 deletions.
6 changes: 3 additions & 3 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 -->115.0.5790.24<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->113.0<!-- GEN:stop --> ||||
| Chromium <!-- GEN:chromium-version -->115.0.5790.75<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->17.0<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->115.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.36.0</AssemblyVersion>
<PackageVersion>$(AssemblyVersion)-beta-1</PackageVersion>
<DriverVersion>1.35.0</DriverVersion>
<DriverVersion>1.36.0</DriverVersion>
<ReleaseVersion>$(AssemblyVersion)</ReleaseVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<NoDefaultExcludes>true</NoDefaultExcludes>
Expand Down
9 changes: 3 additions & 6 deletions src/Playwright.Tests/BrowserContextCSPTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public async Task ShouldBypassCSPMetatag()
{
var page = await context.NewPageAsync();
await page.GotoAsync(Server.Prefix + "/csp.html");
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => page.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
TestUtils.AssertCSPError(exception.Message);
await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => page.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
Assert.Null(await page.EvaluateAsync("window.__injected"));
}
// By-pass CSP and try one more time.
Expand All @@ -58,8 +57,7 @@ public async Task ShouldBypassCSPHeader()
{
var page = await context.NewPageAsync();
await page.GotoAsync(Server.EmptyPage);
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => page.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
TestUtils.AssertCSPError(exception.Message);
await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => page.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
Assert.Null(await page.EvaluateAsync("window.__injected"));
}

Expand Down Expand Up @@ -97,8 +95,7 @@ public async Task ShouldBypassCSPInIframesAsWell()

// Make sure CSP prohibits addScriptTag in an iframe.
var frame = await FrameUtils.AttachFrameAsync(page, "frame1", Server.Prefix + "/csp.html");
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => frame.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
TestUtils.AssertCSPError(exception.Message);
await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => frame.AddScriptTagAsync(new() { Content = "window.__injected = 42;" }));
Assert.Null(await frame.EvaluateAsync<int?>("() => window.__injected"));
}

Expand Down
16 changes: 0 additions & 16 deletions src/Playwright.Tests/BrowserContextRouteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,6 @@ await page.RouteAsync("**/non-empty.html", (route) =>
Assert.AreEqual("context", await response.TextAsync());
}

[PlaywrightTest]
public async Task ShouldThrowOnInvalidRouteUrl()
{
await using var context = await Browser.NewContextAsync();

var regexParseExceptionType = typeof(System.Text.RegularExpressions.Regex).Assembly
.GetType("System.Text.RegularExpressions.RegexParseException", throwOnError: true);

Assert.Throws(regexParseExceptionType, () =>
context.RouteAsync("[", route =>
{
route.ContinueAsync();
})
);
}

[PlaywrightTest("browsercontext-route.spec.ts", "should support the times parameter with route matching")]
public async Task ShouldSupportTheTimesParameterWithRouteMatching()
{
Expand Down
13 changes: 10 additions & 3 deletions src/Playwright.Tests/InterceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,29 @@ public class GlobTests : PageTestEx
public void ShouldWorkWithGlob()
{
Assert.That("https://localhost:8080/foo.js", Does.Match(StringExtensions.GlobToRegex("**/*.js")));
Assert.That("https://localhost:8080/foo.js", Does.Not.Match(StringExtensions.GlobToRegex("**/*.css")));
Assert.That("https://localhost:8080/foo.js", Does.Not.Match(StringExtensions.GlobToRegex("*.js")));
Assert.That("https://localhost:8080/foo.js", Does.Match(StringExtensions.GlobToRegex("https://**/*.js")));
Assert.That("http://localhost:8080/simple/path.js", Does.Match(StringExtensions.GlobToRegex("http://localhost:8080/simple/path.js")));
Assert.That("http://localhost:8080/Simple/path.js", Does.Match(StringExtensions.GlobToRegex("http://localhost:8080/?imple/path.js")));
Assert.That("https://localhost:8080/a.js", Does.Match(StringExtensions.GlobToRegex("**/{a,b}.js")));
Assert.That("https://localhost:8080/b.js", Does.Match(StringExtensions.GlobToRegex("**/{a,b}.js")));
Assert.That("https://localhost:8080/c.js", Does.Not.Match(StringExtensions.GlobToRegex("**/{a,b}.js")));
Assert.That("https://localhost:8080/c.jpg", Does.Match(StringExtensions.GlobToRegex("**/*.{png,jpg,jpeg}")));
Assert.That("https://localhost:8080/c.jpeg", Does.Match(StringExtensions.GlobToRegex("**/*.{png,jpg,jpeg}")));
Assert.That("https://localhost:8080/c.png", Does.Match(StringExtensions.GlobToRegex("**/*.{png,jpg,jpeg}")));
Assert.That("https://localhost:8080/c.css", Does.Not.Match(StringExtensions.GlobToRegex("**/*.{png,jpg,jpeg}")));
Assert.That("https://localhost:8080/foo.js", Does.Not.Match(StringExtensions.GlobToRegex("**/*.css")));
Assert.That("https://localhost:8080/foo.js", Does.Not.Match(StringExtensions.GlobToRegex("*.js")));
Assert.That("https://localhost:8080/c.js", Does.Not.Match(StringExtensions.GlobToRegex("**/{a,b}.js")));
Assert.That("foo.js", Does.Match(StringExtensions.GlobToRegex("foo*")));
Assert.That("foo/bar.js", Does.Not.Match(StringExtensions.GlobToRegex("foo*")));
Assert.That("http://localhost:3000/signin-oidc/foo", Does.Not.Match(StringExtensions.GlobToRegex("http://localhost:3000/signin-oidc*")));
Assert.That("http://localhost:3000/signin-oidcnice", Does.Match(StringExtensions.GlobToRegex("http://localhost:3000/signin-oidc*")));

Assert.AreEqual("^\\?$", StringExtensions.GlobToRegex("\\?"));
Assert.AreEqual("^\\\\$", StringExtensions.GlobToRegex("\\"));
Assert.AreEqual("^\\\\$", StringExtensions.GlobToRegex("\\\\"));
Assert.AreEqual("^\\[$", StringExtensions.GlobToRegex("\\["));
Assert.AreEqual("^\\[$", StringExtensions.GlobToRegex("["));
Assert.AreEqual("^\\$\\^\\+\\.\\*\\(\\)\\|\\?\\{\\}\\[\\]$", StringExtensions.GlobToRegex("$^+.\\*()|\\?\\{\\}[]"));
}

[PlaywrightTest("interception.spec.ts", "should work with ignoreHTTPSErrors")]
Expand Down
8 changes: 8 additions & 0 deletions src/Playwright.Tests/PageEvaluateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

using System.ComponentModel;
using System.Dynamic;
using System.Numerics;
using System.Text.Json;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -72,6 +73,13 @@ public async Task ShouldTransferNegativeInfinity()
Assert.AreEqual(double.NegativeInfinity, result);
}

[PlaywrightTest("page-evaluate.spec.ts", "should transfer bigint")]
public async Task ShouldTransferBigInt()
{
Assert.AreEqual(new BigInteger(42), await Page.EvaluateAsync<BigInteger>("() => 42n"));
Assert.AreEqual(new BigInteger(17), await Page.EvaluateAsync<BigInteger>("a => a", new BigInteger(17)));
}

[PlaywrightTest("page-evaluate.spec.ts", "should roundtrip unserializable values")]
public async Task ShouldRoundtripUnserializableValues()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright.Tests/PageGotoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ public async Task ShouldFailWhenReplacedByAnotherNavigation()
}
else if (TestConstants.IsWebKit)
{
StringAssert.Contains("Navigation interrupted by another one", exception.Message);
StringAssert.Contains("is interrupted by another navigation to", exception.Message);
}
else
{
// Firefox might yield either NS_BINDING_ABORTED or 'navigation interrupted by another one'
Assert.True(exception.Message.Contains("NS_BINDING_ABORTED") || exception.Message.Contains("Navigation interrupted by another one"));
Assert.True(exception.Message.Contains("NS_BINDING_ABORTED") || exception.Message.Contains("is interrupted by another navigation to"));
}
}

Expand Down
38 changes: 23 additions & 15 deletions src/Playwright.Tests/PageRouteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ await Page.RouteAsync("**/empty.html", (route) =>
Assert.AreEqual(new[] { 1 }, intercepted.ToArray());
}

[PlaywrightTest("page-route.spec.ts", "should support ? in glob pattern")]
public async Task ShouldSupportInGlobPattern()
{
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"));

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" }));

await Page.GotoAsync(Server.Prefix + "/index?hello");
StringAssert.Contains("intercepted question mark", await Page.ContentAsync());

await Page.GotoAsync(Server.Prefix + "/index");
StringAssert.Contains("index-no-hello", await Page.ContentAsync());

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

await Page.GotoAsync(Server.Prefix + "/index123hello");
StringAssert.Contains("index123hello", await Page.ContentAsync());
}

[PlaywrightTest("page-route.spec.ts", "should work when POST is redirected with 302")]
public async Task ShouldWorkWhenPostIsRedirectedWith302()
{
Expand Down Expand Up @@ -688,21 +711,6 @@ await Page.RouteAsync("**/cars*", (route) =>
Assert.AreEqual(new[] { "DELETE", "electric", "cars" }, resp);
}

[PlaywrightTest]
public void ShouldThrowOnInvalidRouteUrl()
{
var regexParseExceptionType = typeof(Regex).Assembly
.GetType("System.Text.RegularExpressions.RegexParseException", throwOnError: true);


Assert.Throws(regexParseExceptionType, () =>
Page.RouteAsync("[", route =>
{
route.ContinueAsync();
})
);
}

[PlaywrightTest("page-route.spec.ts", "should support the times parameter with route matching")]
public async Task ShouldSupportTheTimesParameterWithRouteMatching()
{
Expand Down
16 changes: 0 additions & 16 deletions src/Playwright.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,6 @@ internal static void AssertSSLError(string errorMessage)
}
}

internal static void AssertCSPError(string errorMessage)
{
if (TestConstants.IsWebKit)
{
StringAssert.StartsWith("Refused to execute a script because its hash, its nonce, or 'unsafe-inline' appears in neither the script-src directive nor the default-src directive of the Content Security Policy.", errorMessage);
}
else if (TestConstants.IsFirefox)
{
StringAssert.StartsWith("[JavaScript Error: \"Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”).\"", errorMessage);
}
else
{
StringAssert.StartsWith("Refused to execute inline script because it violates the following Content Security Policy directive: \"default-src 'self'\".", errorMessage);
}
}

/// <summary>
/// Removes as much whitespace as possible from a given string. Whitespace
/// that separates letters and/or digits is collapsed to a space character.
Expand Down
6 changes: 3 additions & 3 deletions src/Playwright/API/Generated/IAPIRequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ public partial interface IAPIRequestContext
/// into the URL search parameters:
/// </para>
/// <code>
/// var params = new Dictionary&lt;string, object&gt;()<br/>
/// var queryParams = new Dictionary&lt;string, object&gt;()<br/>
/// {<br/>
/// { "isbn", "1234" },<br/>
/// { "page", 23 },<br/>
/// }<br/>
/// await request.GetAsync("https://example.com/api/getText", new() { Params = params });
/// };<br/>
/// await request.GetAsync("https://example.com/api/getText", new() { Params = queryParams });
/// </code>
/// </summary>
/// <param name="url">Target URL.</param>
Expand Down
2 changes: 1 addition & 1 deletion src/Playwright/API/Generated/IBrowserType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public partial interface IBrowserType
/// <code>
/// var browser = await playwright.Chromium.LaunchAsync(new() {<br/>
/// IgnoreDefaultArgs = new[] { "--mute-audio" }<br/>
/// })
/// });
/// </code>
/// <para>
/// > **Chromium-only** Playwright can also be used to control the Google Chrome or
Expand Down
20 changes: 10 additions & 10 deletions src/Playwright/API/Generated/IFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,19 +703,19 @@ public partial interface IFrame
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches &lt;span&gt;<br/>
/// page.GetByText("world")<br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first &lt;div&gt;<br/>
/// page.GetByText("Hello world")<br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText("Hello", new() { Exact: true })<br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both &lt;div&gt;s<br/>
/// page.GetByText(new Regex("Hello"))<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase))
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
Expand Down Expand Up @@ -744,19 +744,19 @@ public partial interface IFrame
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches &lt;span&gt;<br/>
/// page.GetByText("world")<br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first &lt;div&gt;<br/>
/// page.GetByText("Hello world")<br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText("Hello", new() { Exact: true })<br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both &lt;div&gt;s<br/>
/// page.GetByText(new Regex("Hello"))<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase))
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
Expand Down
20 changes: 10 additions & 10 deletions src/Playwright/API/Generated/IFrameLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,19 @@ public partial interface IFrameLocator
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches &lt;span&gt;<br/>
/// page.GetByText("world")<br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first &lt;div&gt;<br/>
/// page.GetByText("Hello world")<br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText("Hello", new() { Exact: true })<br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both &lt;div&gt;s<br/>
/// page.GetByText(new Regex("Hello"))<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase))
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
Expand Down Expand Up @@ -284,19 +284,19 @@ public partial interface IFrameLocator
/// <para>You can locate by text substring, exact string, or a regular expression:</para>
/// <code>
/// // Matches &lt;span&gt;<br/>
/// page.GetByText("world")<br/>
/// page.GetByText("world");<br/>
/// <br/>
/// // Matches first &lt;div&gt;<br/>
/// page.GetByText("Hello world")<br/>
/// page.GetByText("Hello world");<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText("Hello", new() { Exact: true })<br/>
/// page.GetByText("Hello", new() { Exact = true });<br/>
/// <br/>
/// // Matches both &lt;div&gt;s<br/>
/// page.GetByText(new Regex("Hello"))<br/>
/// page.GetByText(new Regex("Hello"));<br/>
/// <br/>
/// // Matches second &lt;div&gt;<br/>
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase))
/// page.GetByText(new Regex("^hello$", RegexOptions.IgnoreCase));
/// </code>
/// <para>**Details**</para>
/// <para>
Expand Down
2 changes: 1 addition & 1 deletion src/Playwright/API/Generated/IJSHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public partial interface IJSHandle
/// </para>
/// <para>**Usage**</para>
/// <code>
/// var handle = await page.EvaluateHandleAsync("() =&gt; ({window, document}");<br/>
/// var handle = await page.EvaluateHandleAsync("() =&gt; ({ window, document }");<br/>
/// var properties = await handle.GetPropertiesAsync();<br/>
/// var windowHandle = properties["window"];<br/>
/// var documentHandle = properties["document"];<br/>
Expand Down
Loading

0 comments on commit f545f6a

Please sign in to comment.