Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(roll): roll Playwright to 1.40.0-alpha-oct-18-2023 #2757

Merged
merged 4 commits into from
Nov 21, 2023
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,8 +3,8 @@

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->119.0.6045.9<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->17.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->119.0.6045.21<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->118.0.1<!-- 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.39.0</AssemblyVersion>
<PackageVersion>$(AssemblyVersion)</PackageVersion>
<DriverVersion>1.39.0</DriverVersion>
<DriverVersion>1.40.0-alpha-oct-18-2023</DriverVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we roll to 1.40.0 right away?

<ReleaseVersion>$(AssemblyVersion)</ReleaseVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<NoDefaultExcludes>true</NoDefaultExcludes>
Expand Down
2 changes: 1 addition & 1 deletion src/Playwright.Tests/BrowserContextBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public async Task CloseShouldAbortWaitForEvent()
var waitTask = context.WaitForPageAsync();
await context.CloseAsync();
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => waitTask);
Assert.AreEqual("Context closed", exception.Message);
Assert.AreEqual(TestConstants.TargetClosedErrorMessage, exception.Message);
}

[PlaywrightTest("browsercontext-basic.spec.ts", "should not report frameless pages on error")]
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright.Tests/BrowserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public async Task ShouldCreateNewPage()
{
var browser = await Playwright[TestConstants.BrowserName].LaunchAsync();
var page1 = await browser.NewPageAsync();
Assert.That(browser.Contexts, Has.Length.EqualTo(1));
Assert.AreEqual(1, browser.Contexts.Count);

var page2 = await browser.NewPageAsync();
Assert.AreEqual(2, browser.Contexts.Count);

await page1.CloseAsync();
Assert.That(browser.Contexts, Has.Length.EqualTo(1));
Assert.AreEqual(1, browser.Contexts.Count);

await page2.CloseAsync();
await browser.CloseAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright.Tests/BrowserTypeConnectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public async Task ShouldThrowWhenWhenCallingWaitForNavigationAfterDisconnect()

Assert.AreEqual(browser.IsConnected, false);
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(async () => await page.WaitForNavigationAsync());
StringAssert.Contains("Navigation failed because page was closed", exception.Message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, exception.Message);
}

[PlaywrightTest("browsertype-connect.spec.ts", "should reject navigation when browser closes")]
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task ShouldTerminateNetworkWaiters()
async Task CheckTaskHasException(Task task)
{
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(async () => await task);
StringAssert.Contains("Page closed", exception.Message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, exception.Message);
StringAssert.DoesNotContain("Timeout", exception.Message);

}
Expand Down
2 changes: 1 addition & 1 deletion src/Playwright.Tests/ElementHandleEvalOnSelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ public async Task ShouldThrowInCaseOfMissingSelector()
await Page.SetContentAsync(htmlContent);
var elementHandle = await Page.QuerySelectorAsync("#myId");
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => elementHandle.EvalOnSelectorAsync(".a", "node => node.innerText"));
StringAssert.Contains("failed to find element matching selector \".a\"", exception.Message);
StringAssert.Contains("Failed to find element matching selector \".a\"", exception.Message);
}
}
2 changes: 1 addition & 1 deletion src/Playwright.Tests/EvalOnSelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task ShouldThrowErrorIfNoElementIsFound()
{
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(()
=> Page.EvalOnSelectorAsync("section", "e => e.id"));
StringAssert.Contains("failed to find element matching selector \"section\"", exception.Message);
StringAssert.Contains("Failed to find element matching selector \"section\"", exception.Message);
}

[PlaywrightTest("eval-on-selector.spec.ts", "should support >> syntax")]
Expand Down
6 changes: 3 additions & 3 deletions src/Playwright.Tests/PageBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task ShouldRejectAllPromisesWhenPageIsClosed()
newPage.EvaluateAsync<string>("() => new Promise(r => { })"),
newPage.CloseAsync()
));
StringAssert.Contains("Target closed", exception.Message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, exception.Message);
}

[PlaywrightTest("page-basic.spec.ts", "async stacks should work")]
Expand Down Expand Up @@ -147,7 +147,7 @@ public async Task ShouldFailWithErrorUponDisconnect()
var task = Page.WaitForDownloadAsync();
await Page.CloseAsync();
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => task);
StringAssert.Contains("Page closed", exception.Message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, exception.Message);
}

[PlaywrightTest("page-basic.spec.ts", "should have sane user agent")]
Expand Down Expand Up @@ -245,7 +245,7 @@ public async Task ShouldTerminateNetworkWaiters()
for (int i = 0; i < 2; i++)
{
string message = exception.Message;
StringAssert.Contains("Page closed", message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, message);
Assert.That(message, Does.Not.Contain("Timeout"));
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Playwright.Tests/ScreencastTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ public async Task VideoPathSaveAsDoesNotHangImmediatelyAfterLaunchPersistentCont
catch (Exception)
{
}
await page.Video.DeleteAsync();
try
{
await page.Video.DeleteAsync();
}
catch (Exception)
{
}
}

[PlaywrightTest("screencast.spec.ts", "saveAs should throw when no video frames")]
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.Tests/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ internal static class TestConstants
internal static readonly bool IsMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
internal static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
internal static readonly bool IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

internal static readonly string TargetClosedErrorMessage = "Target page, context or browser has been closed";
}
2 changes: 1 addition & 1 deletion src/Playwright.Tests/WorkersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task ShouldEmitCreatedAndDestroyedEvents()
await Page.EvaluateAsync("workerObj => workerObj.terminate()", workerObj);
Assert.AreEqual(worker, await workerDestroyedTcs.Task);
var exception = await PlaywrightAssert.ThrowsAsync<PlaywrightException>(() => workerThisObj.GetPropertyAsync("self"));
StringAssert.IsMatch("(Worker was closed)|(Target closed)", exception.Message);
StringAssert.Contains(TestConstants.TargetClosedErrorMessage, exception.Message);
}

[PlaywrightTest("workers.spec.ts", "should report console logs")]
Expand Down
3 changes: 2 additions & 1 deletion src/Playwright/API/Generated/IBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public partial interface IBrowser
/// cref="IBrowser.NewContextAsync"/> **before** calling <see cref="IBrowser.CloseAsync"/>.
/// </para>
/// </remarks>
Task CloseAsync();
/// <param name="options">Call options</param>
Task CloseAsync(BrowserCloseOptions? options = default);

/// <summary>
/// <para>
Expand Down
3 changes: 2 additions & 1 deletion src/Playwright/API/Generated/IBrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public partial interface IBrowserContext
/// </para>
/// </summary>
/// <remarks><para>The default browser context cannot be closed.</para></remarks>
Task CloseAsync();
/// <param name="options">Call options</param>
Task CloseAsync(BrowserContextCloseOptions? options = default);

/// <summary>
/// <para>
Expand Down
4 changes: 2 additions & 2 deletions src/Playwright/API/Generated/IDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public partial interface IDownload
Task CancelAsync();

/// <summary><para>Returns readable stream for current download or <c>null</c> if download failed.</para></summary>
Task<Stream?> CreateReadStreamAsync();
Task<Stream> CreateReadStreamAsync();

/// <summary><para>Deletes the downloaded file. Will wait for the download to finish if necessary.</para></summary>
Task DeleteAsync();
Expand All @@ -84,7 +84,7 @@ public partial interface IDownload
/// to get suggested file name.
/// </para>
/// </summary>
Task<string?> PathAsync();
Task<string> PathAsync();

/// <summary>
/// <para>
Expand Down
1 change: 0 additions & 1 deletion src/Playwright/API/Generated/IFormData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* SOFTWARE.
*/


#nullable enable

namespace Microsoft.Playwright;
Expand Down
1 change: 0 additions & 1 deletion src/Playwright/API/Generated/IPlaywrightAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* SOFTWARE.
*/


#nullable enable

namespace Microsoft.Playwright;
Expand Down
1 change: 0 additions & 1 deletion src/Playwright/API/Generated/IWebError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* SOFTWARE.
*/


#nullable enable

namespace Microsoft.Playwright;
Expand Down
1 change: 0 additions & 1 deletion src/Playwright/API/Generated/IWebSocketFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* SOFTWARE.
*/


#nullable enable

namespace Microsoft.Playwright;
Expand Down
50 changes: 50 additions & 0 deletions src/Playwright/API/Generated/Options/BrowserCloseOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* MIT License
*
* Copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using System.Text.Json.Serialization;

#nullable enable

namespace Microsoft.Playwright;

public class BrowserCloseOptions
{
public BrowserCloseOptions() { }

public BrowserCloseOptions(BrowserCloseOptions clone)
{
if (clone == null)
{
return;
}

Reason = clone.Reason;
}

/// <summary><para>The reason to be reported to the operations interrupted by the browser closure.</para></summary>
[JsonPropertyName("reason")]
public string? Reason { get; set; }
}

#nullable disable
50 changes: 50 additions & 0 deletions src/Playwright/API/Generated/Options/BrowserContextCloseOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* MIT License
*
* Copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using System.Text.Json.Serialization;

#nullable enable

namespace Microsoft.Playwright;

public class BrowserContextCloseOptions
{
public BrowserContextCloseOptions() { }

public BrowserContextCloseOptions(BrowserContextCloseOptions clone)
{
if (clone == null)
{
return;
}

Reason = clone.Reason;
}

/// <summary><para>The reason to be reported to the operations interrupted by the context closure.</para></summary>
[JsonPropertyName("reason")]
public string? Reason { get; set; }
}

#nullable disable
5 changes: 5 additions & 0 deletions src/Playwright/API/Generated/Options/PageCloseOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ public PageCloseOptions(PageCloseOptions clone)
return;
}

Reason = clone.Reason;
RunBeforeUnload = clone.RunBeforeUnload;
}

/// <summary><para>The reason to be reported to the operations interrupted by the page closure.</para></summary>
[JsonPropertyName("reason")]
public string? Reason { get; set; }

/// <summary>
/// <para>
/// Defaults to <c>false</c>. Whether to run the <a href="https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload">before
Expand Down
43 changes: 43 additions & 0 deletions src/Playwright/API/TargetClosedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* MIT License
*
* Copyright (c) Microsoft Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

using System;
using Microsoft.Playwright.Core;

namespace Microsoft.Playwright;

internal class TargetClosedException : PlaywrightException
{
internal TargetClosedException() : base(DriverMessages.TargetClosedExceptionMessage)
{
}

internal TargetClosedException(string message) : base(message ?? DriverMessages.TargetClosedExceptionMessage)
{
}

internal TargetClosedException(string message, Exception innerException) : base(message, innerException)
{
}
}
Loading
Loading