diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b18272e517..b1989cf15f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: browser: [chromium, firefox, webkit] - os: [windows-latest, ubuntu-latest, macos-latest] + os: [windows-latest, ubuntu-latest, macos-12] steps: - uses: actions/checkout@v2 - name: Setup .NET Core diff --git a/README.md b/README.md index 1fd80535e7..fabe3af36a 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 103.0.5060.24 | ✅ | ✅ | ✅ | +| Chromium 103.0.5060.53 | ✅ | ✅ | ✅ | | WebKit 15.4 | ✅ | ✅ | ✅ | -| Firefox 99.0.1 | ✅ | ✅ | ✅ | +| Firefox 100.0.2 | ✅ | ✅ | ✅ | 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**. diff --git a/src/Common/Version.props b/src/Common/Version.props index 9561ca35b2..683b5906ed 100644 --- a/src/Common/Version.props +++ b/src/Common/Version.props @@ -2,7 +2,7 @@ 1.22.0 $(AssemblyVersion) - 1.23.0-alpha-may-27-2022 + 1.23.0-beta-1656093125000 $(AssemblyVersion) $(AssemblyVersion) true diff --git a/src/Playwright.Tests/BrowserContextLocaleTests.cs b/src/Playwright.Tests/BrowserContextLocaleTests.cs index 936430920f..08f08fc6f9 100644 --- a/src/Playwright.Tests/BrowserContextLocaleTests.cs +++ b/src/Playwright.Tests/BrowserContextLocaleTests.cs @@ -33,7 +33,7 @@ public class BrowserContextLocaleTests : BrowserTestEx [PlaywrightTest("browsercontext-locale.spec.ts", "should affect accept-language header")] public async Task ShouldAffectAcceptLanguageHeader() { - await using var context = await Browser.NewContextAsync(new() { Locale = "fr-CH" }); + await using var context = await Browser.NewContextAsync(new() { Locale = "fr-FR" }); string acceptLanguage = string.Empty; var page = await context.NewPageAsync(); var requestTask = Server.WaitForRequest("/empty.html", c => acceptLanguage = c.Headers["accept-language"]); @@ -42,7 +42,7 @@ await TaskUtils.WhenAll( requestTask, page.GotoAsync(Server.EmptyPage)); - Assert.That(acceptLanguage, Does.StartWith("fr-CH")); + Assert.That(acceptLanguage, Does.StartWith("fr-FR")); } [PlaywrightTest("browsercontext-locale.spec.ts", "should affect navigator.language")] @@ -50,10 +50,10 @@ public async Task ShouldAffectNavigatorLanguage() { await using var context = await Browser.NewContextAsync(new() { - Locale = "fr-CH" + Locale = "fr-FR" }); var page = await context.NewPageAsync(); - Assert.AreEqual("fr-CH", await page.EvaluateAsync("navigator.language")); + Assert.AreEqual("fr-FR", await page.EvaluateAsync("navigator.language")); } [PlaywrightTest("browsercontext-locale.spec.ts", "should format number")] @@ -71,7 +71,7 @@ public async Task ShouldFormatNumber() await using (var context = await Browser.NewContextAsync(new() { - Locale = "fr-CH" + Locale = "fr-FR" })) { var page = await context.NewPageAsync(); @@ -116,7 +116,7 @@ public async Task ShouldFormatNumberInPopups() { await using var context = await Browser.NewContextAsync(new() { - Locale = "fr-CH" + Locale = "fr-FR" }); var page = await context.NewPageAsync(); @@ -137,7 +137,7 @@ public async Task ShouldAffectNavigatorLanguageInPopups() { await using var context = await Browser.NewContextAsync(new() { - Locale = "fr-CH" + Locale = "fr-FR" }); var page = await context.NewPageAsync(); @@ -150,7 +150,7 @@ await TaskUtils.WhenAll( var popup = popupTask.Result; await popup.WaitForLoadStateAsync(LoadState.DOMContentLoaded); - Assert.AreEqual("fr-CH", await popup.EvaluateAsync("() => window.initialNavigatorLanguage")); + Assert.AreEqual("fr-FR", await popup.EvaluateAsync("() => window.initialNavigatorLanguage")); } } } diff --git a/src/Playwright.Tests/BrowserContextServiceWorkerPolicyTests.cs b/src/Playwright.Tests/BrowserContextServiceWorkerPolicyTests.cs new file mode 100644 index 0000000000..af1dc2d261 --- /dev/null +++ b/src/Playwright.Tests/BrowserContextServiceWorkerPolicyTests.cs @@ -0,0 +1,58 @@ +/* + * 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.Threading.Tasks; +using Microsoft.Playwright.NUnit; +using NUnit.Framework; + +namespace Microsoft.Playwright.Tests +{ + public class BrowserContextServiceWorkerPolicyTests : BrowserTestEx + { + [PlaywrightTest("browsercontext-service-worker-policy.spec.ts", "should allow service workers by default")] + public async Task ShouldAllowServiceWorkersByDefault() + { + var context = await Browser.NewContextAsync(); + var page = await context.NewPageAsync(); + await page.GotoAsync(Server.Prefix + "/serviceworkers/empty/sw.html"); + var registrationResult = await page.EvaluateAsync("() => window['registrationPromise']"); + Assert.IsNotNull(registrationResult); + await context.CloseAsync(); + } + + [PlaywrightTest("browsercontext-service-worker-policy.spec.ts", "blocks service worker registration")] + public async Task ShouldBlockServiceWorkerRegistration() + { + var context = await Browser.NewContextAsync(new() + { + ServiceWorkers = ServiceWorkerPolicy.Block + }); + var page = await context.NewPageAsync(); + var (consoleMessage, _) = await TaskUtils.WhenAll(page.WaitForConsoleMessageAsync(), + page.GotoAsync(Server.Prefix + "/serviceworkers/empty/sw.html")); + Assert.AreEqual("Service Worker registration blocked by Playwright", consoleMessage.Text); + await context.CloseAsync(); + } + } +} diff --git a/src/Playwright.Tests/BrowserTests.cs b/src/Playwright.Tests/BrowserTests.cs index dd41305d37..d2177295ef 100644 --- a/src/Playwright.Tests/BrowserTests.cs +++ b/src/Playwright.Tests/BrowserTests.cs @@ -45,6 +45,16 @@ public async Task ShouldCreateNewPage() Assert.That(browser.Contexts, Has.Length.EqualTo(1)); await page2.CloseAsync(); + await browser.CloseAsync(); + } + + [PlaywrightTest("browser.spec.ts", "should return browserType")] + public async Task ShouldReturnBrowserType() + { + var browserType = Playwright[TestConstants.BrowserName]; + var browser = await browserType.LaunchAsync(); + Assert.AreEqual(browser.BrowserType, browserType); + await browser.CloseAsync(); } [PlaywrightTest("browser.spec.ts", "should throw upon second create new page")] diff --git a/src/Playwright.Tests/BrowserTypeConnectOverCDPTests.cs b/src/Playwright.Tests/BrowserTypeConnectOverCDPTests.cs index 559e0b56d8..5e926198db 100644 --- a/src/Playwright.Tests/BrowserTypeConnectOverCDPTests.cs +++ b/src/Playwright.Tests/BrowserTypeConnectOverCDPTests.cs @@ -42,6 +42,7 @@ public async Task ShouldConnectToAnExistingCDPSession() try { IBrowser cdpBrowser = await BrowserType.ConnectOverCDPAsync($"http://localhost:{port}/"); + Assert.AreEqual(cdpBrowser.BrowserType, Playwright.Chromium); var contexts = cdpBrowser.Contexts; Assert.AreEqual(1, cdpBrowser.Contexts.Count); var page = await cdpBrowser.Contexts[0].NewPageAsync(); diff --git a/src/Playwright.Tests/DefaultBrowsercontext2Tests.cs b/src/Playwright.Tests/DefaultBrowsercontext2Tests.cs index ceae2ee07a..816d10841a 100644 --- a/src/Playwright.Tests/DefaultBrowsercontext2Tests.cs +++ b/src/Playwright.Tests/DefaultBrowsercontext2Tests.cs @@ -119,10 +119,10 @@ public async Task ShouldSupportLocaleOption() { var (tmp, context, page) = await LaunchAsync(new() { - Locale = "fr-CH", + Locale = "fr-FR", }); - Assert.AreEqual("fr-CH", await page.EvaluateAsync("() => navigator.language")); + Assert.AreEqual("fr-FR", await page.EvaluateAsync("() => navigator.language")); await context.DisposeAsync(); tmp.Dispose(); @@ -229,40 +229,6 @@ public async Task ShouldRestoreStateFromUserDataDir() } } - [PlaywrightTest("defaultbrowsercontext-2.spec.ts", "should restore cookies from userDataDir")] - [Skip(SkipAttribute.Targets.Chromium | SkipAttribute.Targets.Windows)] - public async Task ShouldRestoreCookiesFromUserDataDir() - { - using var userDataDir = new TempDirectory(); - - await using (var browserContext = await BrowserType.LaunchPersistentContextAsync(userDataDir.Path)) - { - var page = await browserContext.NewPageAsync(); - await page.GotoAsync(Server.EmptyPage); - string documentCookie = await page.EvaluateAsync(@"() => { - document.cookie = 'doSomethingOnlyOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT'; - return document.cookie; - }"); - - Assert.AreEqual("doSomethingOnlyOnce=true", documentCookie); - } - - await using (var browserContext2 = await BrowserType.LaunchPersistentContextAsync(userDataDir.Path)) - { - var page = await browserContext2.NewPageAsync(); - await page.GotoAsync(Server.EmptyPage); - Assert.AreEqual("doSomethingOnlyOnce=true", await page.EvaluateAsync("() => document.cookie")); - } - - using var userDataDir2 = new TempDirectory(); - await using (var browserContext2 = await BrowserType.LaunchPersistentContextAsync(userDataDir2.Path)) - { - var page = await browserContext2.NewPageAsync(); - await page.GotoAsync(Server.EmptyPage); - Assert.That("doSomethingOnlyOnce=true", Is.Not.EqualTo(await page.EvaluateAsync("() => document.cookie"))); - } - } - [PlaywrightTest("defaultbrowsercontext-2.spec.ts", "should have default URL when launching browser")] public async Task ShouldHaveDefaultURLWhenLaunchingBrowser() { diff --git a/src/Playwright.Tests/PageNetworkResponseTests.cs b/src/Playwright.Tests/PageNetworkResponseTests.cs index 5ee0bee15d..65cf09bebb 100644 --- a/src/Playwright.Tests/PageNetworkResponseTests.cs +++ b/src/Playwright.Tests/PageNetworkResponseTests.cs @@ -22,11 +22,10 @@ * SOFTWARE. */ -using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; @@ -255,5 +254,22 @@ public async Task ShouldBehaveTheSameWayForHeadersAndAllHeaders() Assert.AreEqual(response.Headers, allHeaders); #pragma warning restore 0612 } + + [PlaywrightTest("page-network-response.spec.ts", "should report if request was fromServiceWorker")] + public async Task ShouldReportIfRequestWasFromServiceWorker() + { + { + var res = await Page.GotoAsync(Server.Prefix + "/serviceworkers/fetch/sw.html"); + Assert.False(res.FromServiceWorker); + } + await Page.EvaluateAsync("() => window['activationPromise']"); + { + var (res, _) = await TaskUtils.WhenAll( + Page.WaitForResponseAsync(new Regex("example.txt")), + Page.EvaluateAsync("() => fetch('/example.txt')") + ); + Assert.True(res.FromServiceWorker); + } + } } } diff --git a/src/Playwright.Tests/PageRequestInterceptTests.cs b/src/Playwright.Tests/PageRequestInterceptTests.cs index 64becdcec9..39dd7179be 100644 --- a/src/Playwright.Tests/PageRequestInterceptTests.cs +++ b/src/Playwright.Tests/PageRequestInterceptTests.cs @@ -31,7 +31,7 @@ namespace Microsoft.Playwright.Tests { - public class RequestInterceptTests : PageTestEx + public class PageRequestInterceptTests : PageTestEx { [PlaywrightTest("page-request-intercept.spec.ts", "should fulfill intercepted response")] public async Task ShouldFulfillInterceptedResponse() @@ -70,6 +70,9 @@ await route.FulfillAsync(new() Response = response, Status = 201, Body = "", + Headers = new Dictionary { + { "Content-Length", "0" }, + }, }); }); var response = await Page.GotoAsync(Server.Prefix + "/title.html"); diff --git a/src/Playwright/API/Generated/Enums/HarContentPolicy.cs b/src/Playwright/API/Generated/Enums/HarContentPolicy.cs new file mode 100644 index 0000000000..c6175cb707 --- /dev/null +++ b/src/Playwright/API/Generated/Enums/HarContentPolicy.cs @@ -0,0 +1,53 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public enum HarContentPolicy + { + [EnumMember(Value = "omit")] + Omit, + [EnumMember(Value = "embed")] + Embed, + [EnumMember(Value = "attach")] + Attach, + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Enums/HarMode.cs b/src/Playwright/API/Generated/Enums/HarMode.cs new file mode 100644 index 0000000000..e88d76cfe7 --- /dev/null +++ b/src/Playwright/API/Generated/Enums/HarMode.cs @@ -0,0 +1,51 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public enum HarMode + { + [EnumMember(Value = "full")] + Full, + [EnumMember(Value = "minimal")] + Minimal, + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Enums/HarNotFound.cs b/src/Playwright/API/Generated/Enums/HarNotFound.cs new file mode 100644 index 0000000000..666e95460a --- /dev/null +++ b/src/Playwright/API/Generated/Enums/HarNotFound.cs @@ -0,0 +1,51 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public enum HarNotFound + { + [EnumMember(Value = "abort")] + Abort, + [EnumMember(Value = "fallback")] + Fallback, + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Enums/ServiceWorkerPolicy.cs b/src/Playwright/API/Generated/Enums/ServiceWorkerPolicy.cs new file mode 100644 index 0000000000..41c5801d10 --- /dev/null +++ b/src/Playwright/API/Generated/Enums/ServiceWorkerPolicy.cs @@ -0,0 +1,51 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public enum ServiceWorkerPolicy + { + [EnumMember(Value = "allow")] + Allow, + [EnumMember(Value = "block")] + Block, + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/IBrowser.cs b/src/Playwright/API/Generated/IBrowser.cs index 05ffc8ac0c..324774503d 100644 --- a/src/Playwright/API/Generated/IBrowser.cs +++ b/src/Playwright/API/Generated/IBrowser.cs @@ -69,6 +69,9 @@ public partial interface IBrowser /// event EventHandler Disconnected; + /// Get the browser type (chromium, firefox or webkit) that the browser belongs to. + IBrowserType BrowserType { get; } + /// /// /// In case this browser is obtained using , closes diff --git a/src/Playwright/API/Generated/IBrowserContext.cs b/src/Playwright/API/Generated/IBrowserContext.cs index 6c3ee214e9..4bdfa98b63 100644 --- a/src/Playwright/API/Generated/IBrowserContext.cs +++ b/src/Playwright/API/Generated/IBrowserContext.cs @@ -426,10 +426,10 @@ public partial interface IBrowserContext /// /// /// - /// will not intercept requests intercepted by Service - /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// will not intercept requests intercepted + /// by Service Worker. See this + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -486,10 +486,10 @@ public partial interface IBrowserContext /// /// /// - /// will not intercept requests intercepted by Service - /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// will not intercept requests intercepted + /// by Service Worker. See this + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -546,10 +546,10 @@ public partial interface IBrowserContext /// /// /// - /// will not intercept requests intercepted by Service - /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// will not intercept requests intercepted + /// by Service Worker. See this + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -563,6 +563,27 @@ public partial interface IBrowserContext /// Call options Task RouteAsync(Func url, Action handler, BrowserContextRouteOptions? options = default); + /// + /// + /// If specified the network requests that are made in the context will be served from + /// the HAR file. Read more about Replaying + /// from HAR. + /// + /// + /// Playwright will not serve requests intercepted by Service Worker from the HAR file. + /// See this issue. + /// We recommend disabling Service Workers when using request interception by setting + /// to 'block'. + /// + /// + /// + /// Path to a HAR file + /// with prerecorded network data. If path is a relative path, then it is resolved + /// relative to the current working directory. + /// + /// Call options + Task RouteFromHARAsync(string har, BrowserContextRouteFromHAROptions? options = default); + /// /// /// This setting will change the default maximum navigation time for the following methods diff --git a/src/Playwright/API/Generated/ILocator.cs b/src/Playwright/API/Generated/ILocator.cs index 83fb0c44df..96d76cc8de 100644 --- a/src/Playwright/API/Generated/ILocator.cs +++ b/src/Playwright/API/Generated/ILocator.cs @@ -335,8 +335,18 @@ public partial interface ILocator /// /// /// This method narrows existing locator according to the options, for example filters - /// by text. + /// by text. It can be chained to filter multiple times. /// + /// + /// var rowLocator = page.Locator("tr");
+ /// // ...
+ /// await rowLocator
+ /// .Filter(new LocatorFilterOptions { HasText = "text in column 1" })
+ /// .Filter(new LocatorFilterOptions {
+ /// Has = page.Locator("tr", new PageLocatorOptions { HasText = "column 2 button" } )
+ /// })
+ /// .ScreenshotAsync(); + ///
///
/// Call options ILocator Filter(LocatorFilterOptions? options = default); diff --git a/src/Playwright/API/Generated/IPage.cs b/src/Playwright/API/Generated/IPage.cs index d2f6b36ac2..1c71e91141 100644 --- a/src/Playwright/API/Generated/IPage.cs +++ b/src/Playwright/API/Generated/IPage.cs @@ -1428,8 +1428,8 @@ public partial interface IPage /// /// will not intercept requests intercepted by Service /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -1485,8 +1485,8 @@ public partial interface IPage /// /// will not intercept requests intercepted by Service /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -1542,8 +1542,8 @@ public partial interface IPage /// /// will not intercept requests intercepted by Service /// Worker. See this - /// issue. We recommend disabling Service Workers when using request interception. Via - /// await context.addInitScript(() => delete window.navigator.serviceWorker); + /// issue. We recommend disabling Service Workers when using request interception by + /// setting to 'block'. /// /// Enabling routing disables http cache. /// @@ -1557,6 +1557,27 @@ public partial interface IPage /// Call options Task RouteAsync(Func url, Action handler, PageRouteOptions? options = default); + /// + /// + /// If specified the network requests that are made in the page will be served from + /// the HAR file. Read more about Replaying + /// from HAR. + /// + /// + /// Playwright will not serve requests intercepted by Service Worker from the HAR file. + /// See this issue. + /// We recommend disabling Service Workers when using request interception by setting + /// to 'block'. + /// + /// + /// + /// Path to a HAR file + /// with prerecorded network data. If path is a relative path, then it is resolved + /// relative to the current working directory. + /// + /// Call options + Task RouteFromHARAsync(string har, PageRouteFromHAROptions? options = default); + /// Returns the buffer with the captured screenshot. /// Call options Task ScreenshotAsync(PageScreenshotOptions? options = default); diff --git a/src/Playwright/API/Generated/IResponse.cs b/src/Playwright/API/Generated/IResponse.cs index d2a2e43d16..c8dfb9da07 100644 --- a/src/Playwright/API/Generated/IResponse.cs +++ b/src/Playwright/API/Generated/IResponse.cs @@ -54,6 +54,14 @@ public partial interface IResponse /// Returns the that initiated this response. IFrame Frame { get; } + /// + /// + /// Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler + /// (i.e. via FetchEvent.respondWith). + /// + /// + bool FromServiceWorker { get; } + /// /// /// **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use Call options Task ContinueAsync(RouteContinueOptions? options = default); + /// + /// + /// When several routes match the given pattern, they run in the order opposite to their + /// registration. That way the last registered route can always override all the previos + /// ones. In the example below, request will be handled by the bottom-most handler first, + /// then it'll fall back to the previous one and in the end will be aborted by the first + /// registered route. + /// + /// + /// await page.RouteAsync("**/*", route => {
+ /// // Runs last.
+ /// await route.AbortAsync();
+ /// });
+ ///
+ /// await page.RouteAsync("**/*", route => {
+ /// // Runs second.
+ /// await route.FallbackAsync();
+ /// });
+ ///
+ /// await page.RouteAsync("**/*", route => {
+ /// // Runs first.
+ /// await route.FallbackAsync();
+ /// }); + ///
+ /// + /// Registering multiple routes is useful when you want separate handlers to handle + /// different kinds of requests, for example API calls vs page resources or GET requests + /// vs POST requests as in the example below. + /// + /// + /// // Handle GET requests.
+ /// await page.RouteAsync("**/*", route => {
+ /// if (route.Request.Method != "GET") {
+ /// await route.FallbackAsync();
+ /// return;
+ /// }
+ /// // Handling GET only.
+ /// // ...
+ /// });
+ ///
+ /// // Handle POST requests.
+ /// await page.RouteAsync("**/*", route => {
+ /// if (route.Request.Method != "POST") {
+ /// await route.FallbackAsync();
+ /// return;
+ /// }
+ /// // Handling POST only.
+ /// // ...
+ /// }); + ///
+ /// + /// One can also modify request while falling back to the subsequent handler, that way + /// intermediate route handler can modify url, method, headers and postData of the request. + /// + /// + /// await page.RouteAsync("**/*", route =>
+ /// {
+ /// var headers = new Dictionary<string, string>(route.Request.Headers) { { "foo", "foo-value" } };
+ /// headers.Remove("bar");
+ /// route.FallbackAsync(headers);
+ /// }); + ///
+ ///
+ /// Call options + Task FallbackAsync(RouteFallbackOptions? options = default); + /// /// Fulfills route's request with given response. /// An example of fulfilling all requests with 404 responses: diff --git a/src/Playwright/API/Generated/Options/BrowserContextRouteFromHAROptions.cs b/src/Playwright/API/Generated/Options/BrowserContextRouteFromHAROptions.cs new file mode 100644 index 0000000000..8461259598 --- /dev/null +++ b/src/Playwright/API/Generated/Options/BrowserContextRouteFromHAROptions.cs @@ -0,0 +1,101 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public class BrowserContextRouteFromHAROptions + { + public BrowserContextRouteFromHAROptions() { } + + public BrowserContextRouteFromHAROptions(BrowserContextRouteFromHAROptions clone) + { + if (clone == null) + { + return; + } + + NotFound = clone.NotFound; + UrlString = clone.UrlString; + UrlRegex = clone.UrlRegex; + UrlFunc = clone.UrlFunc; + } + + /// + /// + /// If set to 'abort' any request not found in the HAR file will be aborted. + /// If set to 'fallback' falls through to the next route handler in the handler chain. + /// + /// Defaults to abort. + /// + [JsonPropertyName("notFound")] + public HarNotFound? NotFound { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlString")] + public string? UrlString { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlRegex")] + public Regex? UrlRegex { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlFunc")] + public Func? UrlFunc { get; set; } + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Options/BrowserNewContextOptions.cs b/src/Playwright/API/Generated/Options/BrowserNewContextOptions.cs index 638b95dea3..894200b93a 100644 --- a/src/Playwright/API/Generated/Options/BrowserNewContextOptions.cs +++ b/src/Playwright/API/Generated/Options/BrowserNewContextOptions.cs @@ -67,12 +67,17 @@ public BrowserNewContextOptions(BrowserNewContextOptions clone) Offline = clone.Offline; Permissions = clone.Permissions; Proxy = clone.Proxy; + RecordHarContent = clone.RecordHarContent; + RecordHarMode = clone.RecordHarMode; RecordHarOmitContent = clone.RecordHarOmitContent; RecordHarPath = clone.RecordHarPath; + RecordHarUrlFilterString = clone.RecordHarUrlFilterString; + RecordHarUrlFilterRegex = clone.RecordHarUrlFilterRegex; RecordVideoDir = clone.RecordVideoDir; RecordVideoSize = clone.RecordVideoSize; ReducedMotion = clone.ReducedMotion; ScreenSize = clone.ScreenSize; + ServiceWorkers = clone.ServiceWorkers; StorageState = clone.StorageState; StorageStatePath = clone.StorageStatePath; StrictSelectors = clone.StrictSelectors; @@ -221,6 +226,27 @@ public BrowserNewContextOptions(BrowserNewContextOptions clone) [JsonPropertyName("proxy")] public Proxy? Proxy { get; set; } + /// + /// + /// Optional setting to control resource content management. If omit is specified, + /// content is not persisted. If attach is specified, resources are persistet + /// as separate files and all of these files are archived along with the HAR file. Defaults + /// to embed, which stores content inline the HAR file as per HAR specification. + /// + /// + [JsonPropertyName("recordHarContent")] + public HarContentPolicy? RecordHarContent { get; set; } + + /// + /// + /// When set to minimal, only record information necessary for routing from HAR. + /// This omits sizes, timing, page, cookies, security and other types of HAR information + /// that are not used when replaying from HAR. Defaults to full. + /// + /// + [JsonPropertyName("recordHarMode")] + public HarMode? RecordHarMode { get; set; } + /// /// /// Optional setting to control whether to omit request content from the HAR. Defaults @@ -241,6 +267,12 @@ public BrowserNewContextOptions(BrowserNewContextOptions clone) [JsonPropertyName("recordHarPath")] public string? RecordHarPath { get; set; } + [JsonPropertyName("recordHarUrlFilterString")] + public string? RecordHarUrlFilterString { get; set; } + + [JsonPropertyName("recordHarUrlFilterRegex")] + public Regex? RecordHarUrlFilterRegex { get; set; } + /// /// /// Enables video recording for all pages into the specified directory. If not specified @@ -281,6 +313,19 @@ public BrowserNewContextOptions(BrowserNewContextOptions clone) [JsonPropertyName("screen")] public ScreenSize? ScreenSize { get; set; } + /// + /// Whether to allow sites to register Service workers. Defaults to 'allow'. + /// + /// + /// 'allow': Service + /// Workers can be registered. + /// + /// 'block': Playwright will block all registration of Service Workers. + /// + /// + [JsonPropertyName("serviceWorkers")] + public ServiceWorkerPolicy? ServiceWorkers { get; set; } + /// /// /// Populates context with given storage state. This option can be used to initialize @@ -302,7 +347,7 @@ public BrowserNewContextOptions(BrowserNewContextOptions clone) /// /// - /// It specified, enables strict selectors mode for this context. In the strict selectors + /// If specified, enables strict selectors mode for this context. In the strict selectors /// mode all operations on selectors that imply single target DOM element will throw /// when more than one element matches the selector. See to learn /// more about the strict mode. diff --git a/src/Playwright/API/Generated/Options/BrowserNewPageOptions.cs b/src/Playwright/API/Generated/Options/BrowserNewPageOptions.cs index 9a66abc60b..4cf9d3eb13 100644 --- a/src/Playwright/API/Generated/Options/BrowserNewPageOptions.cs +++ b/src/Playwright/API/Generated/Options/BrowserNewPageOptions.cs @@ -67,12 +67,17 @@ public BrowserNewPageOptions(BrowserNewPageOptions clone) Offline = clone.Offline; Permissions = clone.Permissions; Proxy = clone.Proxy; + RecordHarContent = clone.RecordHarContent; + RecordHarMode = clone.RecordHarMode; RecordHarOmitContent = clone.RecordHarOmitContent; RecordHarPath = clone.RecordHarPath; + RecordHarUrlFilterString = clone.RecordHarUrlFilterString; + RecordHarUrlFilterRegex = clone.RecordHarUrlFilterRegex; RecordVideoDir = clone.RecordVideoDir; RecordVideoSize = clone.RecordVideoSize; ReducedMotion = clone.ReducedMotion; ScreenSize = clone.ScreenSize; + ServiceWorkers = clone.ServiceWorkers; StorageState = clone.StorageState; StorageStatePath = clone.StorageStatePath; StrictSelectors = clone.StrictSelectors; @@ -221,6 +226,27 @@ public BrowserNewPageOptions(BrowserNewPageOptions clone) [JsonPropertyName("proxy")] public Proxy? Proxy { get; set; } + /// + /// + /// Optional setting to control resource content management. If omit is specified, + /// content is not persisted. If attach is specified, resources are persistet + /// as separate files and all of these files are archived along with the HAR file. Defaults + /// to embed, which stores content inline the HAR file as per HAR specification. + /// + /// + [JsonPropertyName("recordHarContent")] + public HarContentPolicy? RecordHarContent { get; set; } + + /// + /// + /// When set to minimal, only record information necessary for routing from HAR. + /// This omits sizes, timing, page, cookies, security and other types of HAR information + /// that are not used when replaying from HAR. Defaults to full. + /// + /// + [JsonPropertyName("recordHarMode")] + public HarMode? RecordHarMode { get; set; } + /// /// /// Optional setting to control whether to omit request content from the HAR. Defaults @@ -241,6 +267,12 @@ public BrowserNewPageOptions(BrowserNewPageOptions clone) [JsonPropertyName("recordHarPath")] public string? RecordHarPath { get; set; } + [JsonPropertyName("recordHarUrlFilterString")] + public string? RecordHarUrlFilterString { get; set; } + + [JsonPropertyName("recordHarUrlFilterRegex")] + public Regex? RecordHarUrlFilterRegex { get; set; } + /// /// /// Enables video recording for all pages into the specified directory. If not specified @@ -281,6 +313,19 @@ public BrowserNewPageOptions(BrowserNewPageOptions clone) [JsonPropertyName("screen")] public ScreenSize? ScreenSize { get; set; } + /// + /// Whether to allow sites to register Service workers. Defaults to 'allow'. + /// + /// + /// 'allow': Service + /// Workers can be registered. + /// + /// 'block': Playwright will block all registration of Service Workers. + /// + /// + [JsonPropertyName("serviceWorkers")] + public ServiceWorkerPolicy? ServiceWorkers { get; set; } + /// /// /// Populates context with given storage state. This option can be used to initialize @@ -302,7 +347,7 @@ public BrowserNewPageOptions(BrowserNewPageOptions clone) /// /// - /// It specified, enables strict selectors mode for this context. In the strict selectors + /// If specified, enables strict selectors mode for this context. In the strict selectors /// mode all operations on selectors that imply single target DOM element will throw /// when more than one element matches the selector. See to learn /// more about the strict mode. diff --git a/src/Playwright/API/Generated/Options/BrowserTypeLaunchPersistentContextOptions.cs b/src/Playwright/API/Generated/Options/BrowserTypeLaunchPersistentContextOptions.cs index 3987ce7566..81d03c5680 100644 --- a/src/Playwright/API/Generated/Options/BrowserTypeLaunchPersistentContextOptions.cs +++ b/src/Playwright/API/Generated/Options/BrowserTypeLaunchPersistentContextOptions.cs @@ -80,12 +80,17 @@ public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentCont Offline = clone.Offline; Permissions = clone.Permissions; Proxy = clone.Proxy; + RecordHarContent = clone.RecordHarContent; + RecordHarMode = clone.RecordHarMode; RecordHarOmitContent = clone.RecordHarOmitContent; RecordHarPath = clone.RecordHarPath; + RecordHarUrlFilterString = clone.RecordHarUrlFilterString; + RecordHarUrlFilterRegex = clone.RecordHarUrlFilterRegex; RecordVideoDir = clone.RecordVideoDir; RecordVideoSize = clone.RecordVideoSize; ReducedMotion = clone.ReducedMotion; ScreenSize = clone.ScreenSize; + ServiceWorkers = clone.ServiceWorkers; SlowMo = clone.SlowMo; StrictSelectors = clone.StrictSelectors; Timeout = clone.Timeout; @@ -327,6 +332,27 @@ public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentCont [JsonPropertyName("proxy")] public Proxy? Proxy { get; set; } + /// + /// + /// Optional setting to control resource content management. If omit is specified, + /// content is not persisted. If attach is specified, resources are persistet + /// as separate files and all of these files are archived along with the HAR file. Defaults + /// to embed, which stores content inline the HAR file as per HAR specification. + /// + /// + [JsonPropertyName("recordHarContent")] + public HarContentPolicy? RecordHarContent { get; set; } + + /// + /// + /// When set to minimal, only record information necessary for routing from HAR. + /// This omits sizes, timing, page, cookies, security and other types of HAR information + /// that are not used when replaying from HAR. Defaults to full. + /// + /// + [JsonPropertyName("recordHarMode")] + public HarMode? RecordHarMode { get; set; } + /// /// /// Optional setting to control whether to omit request content from the HAR. Defaults @@ -347,6 +373,12 @@ public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentCont [JsonPropertyName("recordHarPath")] public string? RecordHarPath { get; set; } + [JsonPropertyName("recordHarUrlFilterString")] + public string? RecordHarUrlFilterString { get; set; } + + [JsonPropertyName("recordHarUrlFilterRegex")] + public Regex? RecordHarUrlFilterRegex { get; set; } + /// /// /// Enables video recording for all pages into the specified directory. If not specified @@ -387,6 +419,19 @@ public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentCont [JsonPropertyName("screen")] public ScreenSize? ScreenSize { get; set; } + /// + /// Whether to allow sites to register Service workers. Defaults to 'allow'. + /// + /// + /// 'allow': Service + /// Workers can be registered. + /// + /// 'block': Playwright will block all registration of Service Workers. + /// + /// + [JsonPropertyName("serviceWorkers")] + public ServiceWorkerPolicy? ServiceWorkers { get; set; } + /// /// /// Slows down Playwright operations by the specified amount of milliseconds. Useful @@ -398,7 +443,7 @@ public BrowserTypeLaunchPersistentContextOptions(BrowserTypeLaunchPersistentCont /// /// - /// It specified, enables strict selectors mode for this context. In the strict selectors + /// If specified, enables strict selectors mode for this context. In the strict selectors /// mode all operations on selectors that imply single target DOM element will throw /// when more than one element matches the selector. See to learn /// more about the strict mode. diff --git a/src/Playwright/API/Generated/Options/LocatorAssertionsToContainTextOptions.cs b/src/Playwright/API/Generated/Options/LocatorAssertionsToContainTextOptions.cs index 4c808683de..9181cb154d 100644 --- a/src/Playwright/API/Generated/Options/LocatorAssertionsToContainTextOptions.cs +++ b/src/Playwright/API/Generated/Options/LocatorAssertionsToContainTextOptions.cs @@ -50,10 +50,20 @@ public LocatorAssertionsToContainTextOptions(LocatorAssertionsToContainTextOptio return; } + IgnoreCase = clone.IgnoreCase; Timeout = clone.Timeout; UseInnerText = clone.UseInnerText; } + /// + /// + /// Whether to perform case-insensitive match. option + /// takes precedence over the corresponding regular expression flag if specified. + /// + /// + [JsonPropertyName("ignoreCase")] + public bool? IgnoreCase { get; set; } + /// Time to retry the assertion for. [JsonPropertyName("timeout")] public float? Timeout { get; set; } diff --git a/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveTextOptions.cs b/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveTextOptions.cs index 0b7d52e2a8..33c9e43b51 100644 --- a/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveTextOptions.cs +++ b/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveTextOptions.cs @@ -50,10 +50,20 @@ public LocatorAssertionsToHaveTextOptions(LocatorAssertionsToHaveTextOptions clo return; } + IgnoreCase = clone.IgnoreCase; Timeout = clone.Timeout; UseInnerText = clone.UseInnerText; } + /// + /// + /// Whether to perform case-insensitive match. option + /// takes precedence over the corresponding regular expression flag if specified. + /// + /// + [JsonPropertyName("ignoreCase")] + public bool? IgnoreCase { get; set; } + /// Time to retry the assertion for. [JsonPropertyName("timeout")] public float? Timeout { get; set; } diff --git a/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveValuesOptions.cs b/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveValuesOptions.cs new file mode 100644 index 0000000000..e908bb4ba8 --- /dev/null +++ b/src/Playwright/API/Generated/Options/LocatorAssertionsToHaveValuesOptions.cs @@ -0,0 +1,62 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public class LocatorAssertionsToHaveValuesOptions + { + public LocatorAssertionsToHaveValuesOptions() { } + + public LocatorAssertionsToHaveValuesOptions(LocatorAssertionsToHaveValuesOptions clone) + { + if (clone == null) + { + return; + } + + Timeout = clone.Timeout; + } + + /// Time to retry the assertion for. + [JsonPropertyName("timeout")] + public float? Timeout { get; set; } + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Options/PageRouteFromHAROptions.cs b/src/Playwright/API/Generated/Options/PageRouteFromHAROptions.cs new file mode 100644 index 0000000000..56c3b82c8b --- /dev/null +++ b/src/Playwright/API/Generated/Options/PageRouteFromHAROptions.cs @@ -0,0 +1,101 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public class PageRouteFromHAROptions + { + public PageRouteFromHAROptions() { } + + public PageRouteFromHAROptions(PageRouteFromHAROptions clone) + { + if (clone == null) + { + return; + } + + NotFound = clone.NotFound; + UrlString = clone.UrlString; + UrlRegex = clone.UrlRegex; + UrlFunc = clone.UrlFunc; + } + + /// + /// + /// If set to 'abort' any request not found in the HAR file will be aborted. + /// If set to 'fallback' missing requests will be sent to the network. + /// + /// Defaults to abort. + /// + [JsonPropertyName("notFound")] + public HarNotFound? NotFound { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlString")] + public string? UrlString { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlRegex")] + public Regex? UrlRegex { get; set; } + + /// + /// + /// A glob pattern, regular expression or predicate to match the request URL. Only requests + /// with URL matching the pattern will be surved from the HAR file. If not specified, + /// all requests are served from the HAR file. + /// + /// + [JsonPropertyName("urlFunc")] + public Func? UrlFunc { get; set; } + } +} + +#nullable disable diff --git a/src/Playwright/API/Generated/Options/RouteFallbackOptions.cs b/src/Playwright/API/Generated/Options/RouteFallbackOptions.cs new file mode 100644 index 0000000000..fafaf69a33 --- /dev/null +++ b/src/Playwright/API/Generated/Options/RouteFallbackOptions.cs @@ -0,0 +1,83 @@ +/* + * 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 System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; + +#nullable enable + +namespace Microsoft.Playwright +{ + public class RouteFallbackOptions + { + public RouteFallbackOptions() { } + + public RouteFallbackOptions(RouteFallbackOptions clone) + { + if (clone == null) + { + return; + } + + Headers = clone.Headers; + Method = clone.Method; + PostData = clone.PostData; + Url = clone.Url; + } + + /// If set changes the request HTTP headers. Header values will be converted to a string. + [JsonPropertyName("headers")] + public IEnumerable>? Headers { get; set; } + + /// If set changes the request method (e.g. GET or POST) + [JsonPropertyName("method")] + public string? Method { get; set; } + + /// If set changes the post data of request + [JsonPropertyName("postData")] + public byte[]? PostData { get; set; } + + /// + /// + /// If set changes the request URL. New URL must have same protocol as original one. + /// Changing the URL won't affect the route matching, all the routes are matched using + /// the original request URL. + /// + /// + [JsonPropertyName("url")] + public string? Url { get; set; } + } +} + +#nullable disable diff --git a/src/Playwright/Core/APIRequest.cs b/src/Playwright/Core/APIRequest.cs index 91ee986300..4f728805fd 100644 --- a/src/Playwright/Core/APIRequest.cs +++ b/src/Playwright/Core/APIRequest.cs @@ -48,7 +48,6 @@ async Task IAPIRequest.NewContextAsync(APIRequestNewContextO options?.StorageState, options?.StorageStatePath) .ConfigureAwait(false); - context._tracing._localUtils = _playwright._utils; context._request = this; return context; } diff --git a/src/Playwright/Core/Browser.cs b/src/Playwright/Core/Browser.cs index 4107c1afa6..6b99c96e67 100644 --- a/src/Playwright/Core/Browser.cs +++ b/src/Playwright/Core/Browser.cs @@ -62,7 +62,7 @@ internal Browser(IChannelOwner parent, string guid, BrowserInitializer initializ internal List BrowserContextsList { get; } = new(); - internal LocalUtils LocalUtils { get; set; } + public IBrowserType BrowserType { get; internal set; } public async Task CloseAsync() { @@ -109,6 +109,7 @@ public async Task NewContextAsync(BrowserNewContextOptions opti recordVideo: GetVideoArgs(options.RecordVideoDir, options.RecordVideoSize), storageState: options.StorageState, storageStatePath: options.StorageStatePath, + serviceWorkers: options.ServiceWorkers, timezoneId: options.TimezoneId, userAgent: options.UserAgent, viewportSize: options.ViewportSize, @@ -118,7 +119,6 @@ public async Task NewContextAsync(BrowserNewContextOptions opti forcedColors: options.ForcedColors).ConfigureAwait(false)).Object; context.Options = options; - ((Tracing)context.Tracing).LocalUtils = LocalUtils; BrowserContextsList.Add(context); return context; @@ -157,6 +157,7 @@ public async Task NewPageAsync(BrowserNewPageOptions options = default) Proxy = options.Proxy, StorageState = options.StorageState, StorageStatePath = options.StorageStatePath, + ServiceWorkers = options.ServiceWorkers, BaseURL = options.BaseURL, StrictSelectors = options.StrictSelectors, }; diff --git a/src/Playwright/Core/BrowserContext.cs b/src/Playwright/Core/BrowserContext.cs index aeca6873dd..461555e597 100644 --- a/src/Playwright/Core/BrowserContext.cs +++ b/src/Playwright/Core/BrowserContext.cs @@ -480,5 +480,7 @@ private Task ExposeBindingAsync(string name, Delegate callback, bool handle = fa return Channel.ExposeBindingAsync(name, handle); } + + public Task RouteFromHARAsync(string har, BrowserContextRouteFromHAROptions options = null) => throw new NotImplementedException(); } } diff --git a/src/Playwright/Core/BrowserType.cs b/src/Playwright/Core/BrowserType.cs index b781f82df0..778cd47c63 100644 --- a/src/Playwright/Core/BrowserType.cs +++ b/src/Playwright/Core/BrowserType.cs @@ -77,7 +77,7 @@ public async Task LaunchAsync(BrowserTypeLaunchOptions options = defau slowMo: options.SlowMo, ignoreDefaultArgs: options.IgnoreDefaultArgs, ignoreAllDefaultArgs: options.IgnoreAllDefaultArgs).ConfigureAwait(false)).Object; - browser.LocalUtils = Playwright._utils; + browser.BrowserType = this; return browser; } @@ -123,6 +123,7 @@ public async Task LaunchPersistentContextAsync(string userDataD recordHarPath: options.RecordHarPath, recordHarOmitContent: options.RecordHarOmitContent, recordVideo: Browser.GetVideoArgs(options.RecordVideoDir, options.RecordVideoSize), + serviceWorkers: options.ServiceWorkers, ignoreDefaultArgs: options.IgnoreDefaultArgs, ignoreAllDefaultArgs: options.IgnoreAllDefaultArgs, baseUrl: options.BaseURL, @@ -136,7 +137,6 @@ public async Task LaunchPersistentContextAsync(string userDataD RecordHarPath = options.RecordHarPath, RecordHarOmitContent = options.RecordHarOmitContent, }; - ((Core.Tracing)context.Tracing).LocalUtils = Playwright._utils; return context; } @@ -154,7 +154,7 @@ void ClosePipe() pipe.CloseAsync().IgnoreException(); } #pragma warning disable CA2000 // Dispose objects before losing scope - var connection = new Connection(); + var connection = new Connection(_channel.Connection.LocalUtils); #pragma warning restore CA2000 connection.MarkAsRemote(); connection.Close += (_, _) => ClosePipe(); @@ -218,7 +218,7 @@ async Task CreateBrowserAsync() browser = playwright.PreLaunchedBrowser; browser.ShouldCloseConnectionOnClose = true; browser.Disconnected += (_, _) => ClosePipe(); - browser.LocalUtils = Playwright._utils; + browser.BrowserType = this; return playwright.PreLaunchedBrowser; } var task = CreateBrowserAsync(); @@ -239,7 +239,7 @@ public async Task ConnectOverCDPAsync(string endpointURL, BrowserTypeC { browser.BrowserContextsList.Add(defaultContextValue.ToObject(_channel.Connection.DefaultJsonSerializerOptions)); } - browser.LocalUtils = Playwright._utils; + browser.BrowserType = this; return browser; } } diff --git a/src/Playwright/Core/Frame.cs b/src/Playwright/Core/Frame.cs index f9426bf1bd..4c50a0b166 100644 --- a/src/Playwright/Core/Frame.cs +++ b/src/Playwright/Core/Frame.cs @@ -64,6 +64,14 @@ internal Frame(IChannelOwner parent, string guid, FrameInitializer initializer) { _loadStates.Remove(e.Remove.Value); } + if (this.ParentFrame == null && e.Add == WaitUntilState.Load && this.Page != null) + { + (this.Page as Page).FireLoad(); + } + if (this.ParentFrame == null && e.Add == WaitUntilState.DOMContentLoaded && this.Page != null) + { + (this.Page as Page).FireDOMContentLoaded(); + } } }; diff --git a/src/Playwright/Core/LocalUtils.cs b/src/Playwright/Core/LocalUtils.cs index 116e0f7190..a1dfd658c5 100644 --- a/src/Playwright/Core/LocalUtils.cs +++ b/src/Playwright/Core/LocalUtils.cs @@ -33,7 +33,7 @@ namespace Microsoft.Playwright.Core { - internal partial class LocalUtils : ChannelOwnerBase, IChannelOwner, ILocalUtils + internal partial class LocalUtils : ChannelOwnerBase, IChannelOwner { private readonly LocalUtilsChannel _channel; diff --git a/src/Playwright/Core/Page.cs b/src/Playwright/Core/Page.cs index f9b69b4b4d..97474c4f23 100644 --- a/src/Playwright/Core/Page.cs +++ b/src/Playwright/Core/Page.cs @@ -103,7 +103,6 @@ internal Page(IChannelOwner parent, string guid, PageInitializer initializer) : } }; _channel.Console += (_, e) => Console?.Invoke(this, e); - _channel.DOMContentLoaded += (_, _) => DOMContentLoaded?.Invoke(this, this); _channel.Download += (_, e) => Download?.Invoke(this, new Download(this, e.Url, e.SuggestedFilename, e.Artifact.Object)); _channel.PageError += (_, e) => { @@ -115,7 +114,6 @@ internal Page(IChannelOwner parent, string guid, PageInitializer initializer) : PageError?.Invoke(this, $"{e.Error.Name}: {e.Error.Message}"); }; - _channel.Load += (_, _) => Load?.Invoke(this, this); _channel.Video += (_, e) => ForceVideo().ArtifactReady(e.Artifact); _channel.FileChooser += (_, e) => _fileChooserEventHandler?.Invoke(this, new FileChooser(this, e.Element.Object, e.IsMultiple)); @@ -974,6 +972,10 @@ internal void OnFrameNavigated(Frame frame) internal void FireResponse(IResponse response) => Response?.Invoke(this, response); + internal void FireLoad() => Load?.Invoke(this, this); + + internal void FireDOMContentLoaded() => DOMContentLoaded?.Invoke(this, this); + private Task RouteAsync(Regex urlRegex, Func urlFunc, Action handler, PageRouteOptions options) => RouteAsync(new() { @@ -1132,5 +1134,7 @@ private FrameSetInputFilesOptions Map(PageSetInputFilesOptions options) Strict = options.Strict, }; } + + public Task RouteFromHARAsync(string har, PageRouteFromHAROptions options = null) => throw new NotImplementedException(); } } diff --git a/src/Playwright/Core/PlaywrightImpl.cs b/src/Playwright/Core/PlaywrightImpl.cs index 30c244d999..cceb2fc587 100644 --- a/src/Playwright/Core/PlaywrightImpl.cs +++ b/src/Playwright/Core/PlaywrightImpl.cs @@ -42,7 +42,6 @@ internal class PlaywrightImpl : ChannelOwnerBase, IPlaywright, IChannelOwner _devices = new(StringComparer.InvariantCultureIgnoreCase); @@ -51,9 +50,7 @@ internal PlaywrightImpl(IChannelOwner parent, string guid, PlaywrightInitializer { _connection = parent.Connection; _initializer = initializer; - _utils = initializer.Utils; _channel = new(guid, parent.Connection, this); - _utils = initializer.Utils; foreach (var entry in initializer.DeviceDescriptors) { diff --git a/src/Playwright/Core/Response.cs b/src/Playwright/Core/Response.cs index 107457d913..f213b4d86a 100644 --- a/src/Playwright/Core/Response.cs +++ b/src/Playwright/Core/Response.cs @@ -67,6 +67,8 @@ internal Response(IChannelOwner parent, string guid, ResponseInitializer initial public string Url => _initializer.Url; + public bool FromServiceWorker => _initializer.FromServiceWorker; + ChannelBase IChannelOwner.Channel => _channel; IChannel IChannelOwner.Channel => _channel; diff --git a/src/Playwright/Core/Route.cs b/src/Playwright/Core/Route.cs index 6d66f4dec1..5178833b06 100644 --- a/src/Playwright/Core/Route.cs +++ b/src/Playwright/Core/Route.cs @@ -185,5 +185,7 @@ private async Task> NormalizeFulfillParametersAsync( ["fetchResponseUid"] = fetchResponseUid, }; } + + public Task FallbackAsync(RouteFallbackOptions options = null) => throw new NotImplementedException(); } } diff --git a/src/Playwright/Core/Tracing.cs b/src/Playwright/Core/Tracing.cs index 8af00aec5e..e8e0384b64 100644 --- a/src/Playwright/Core/Tracing.cs +++ b/src/Playwright/Core/Tracing.cs @@ -32,15 +32,11 @@ internal class Tracing : ChannelOwnerBase, IChannelOwner, ITracing { private readonly TracingChannel _channel; - internal LocalUtils _localUtils; - public Tracing(IChannelOwner parent, string guid) : base(parent, guid) { _channel = new(guid, parent.Connection, this); } - internal LocalUtils LocalUtils { get; set; } - ChannelBase IChannelOwner.Channel => _channel; IChannel IChannelOwner.Channel => _channel; @@ -109,7 +105,7 @@ private async Task DoStopChunkAsync(string filePath) // Add local sources to the remote trace if necessary. if (sourceEntries.Count > 0) { - await LocalUtils.ZipAsync(filePath, sourceEntries).ConfigureAwait(false); + await _channel.Connection.LocalUtils.ZipAsync(filePath, sourceEntries).ConfigureAwait(false); } } } diff --git a/src/Playwright/Transport/Channels/BrowserChannel.cs b/src/Playwright/Transport/Channels/BrowserChannel.cs index 5e4d8fc000..23a5976deb 100644 --- a/src/Playwright/Transport/Channels/BrowserChannel.cs +++ b/src/Playwright/Transport/Channels/BrowserChannel.cs @@ -74,6 +74,7 @@ internal Task NewContextAsync( Dictionary recordVideo = null, string storageState = null, string storageStatePath = null, + ServiceWorkerPolicy? serviceWorkers = default, string timezoneId = null, string userAgent = null, ViewportSize viewportSize = default, @@ -88,6 +89,7 @@ internal Task NewContextAsync( { "colorScheme", colorScheme }, { "reducedMotion", reducedMotion }, { "deviceScaleFactor", deviceScaleFactor }, + { "serviceWorkers", serviceWorkers }, }; if (extraHTTPHeaders != null) diff --git a/src/Playwright/Transport/Channels/BrowserTypeChannel.cs b/src/Playwright/Transport/Channels/BrowserTypeChannel.cs index 0ea9fa434c..106f888af6 100644 --- a/src/Playwright/Transport/Channels/BrowserTypeChannel.cs +++ b/src/Playwright/Transport/Channels/BrowserTypeChannel.cs @@ -124,6 +124,7 @@ internal Task LaunchPersistentContextAsync( string recordHarPath = default, bool? recordHarOmitContent = default, Dictionary recordVideo = default, + ServiceWorkerPolicy? serviceWorkers = default, IEnumerable ignoreDefaultArgs = default, bool? ignoreAllDefaultArgs = default, string baseUrl = default, @@ -151,6 +152,7 @@ internal Task LaunchPersistentContextAsync( { "ignoreHTTPSErrors", ignoreHTTPSErrors }, { "bypassCSP", bypassCSP }, { "strictSelectors", strictSelectors }, + { "serviceWorkers", serviceWorkers }, }; if (viewportSize?.Width == -1) diff --git a/src/Playwright/Transport/Channels/PageChannel.cs b/src/Playwright/Transport/Channels/PageChannel.cs index cf0b1e152b..90f951ac11 100644 --- a/src/Playwright/Transport/Channels/PageChannel.cs +++ b/src/Playwright/Transport/Channels/PageChannel.cs @@ -45,8 +45,6 @@ public PageChannel(string guid, Connection connection, Page owner) : base(guid, internal event EventHandler WebSocket; - internal event EventHandler DOMContentLoaded; - internal event EventHandler Popup; internal event EventHandler BindingCall; @@ -67,8 +65,6 @@ public PageChannel(string guid, Connection connection, Page owner) : base(guid, internal event EventHandler FileChooser; - internal event EventHandler Load; - internal event EventHandler Worker; internal event EventHandler Video; @@ -83,12 +79,6 @@ internal override void OnMessage(string method, JsonElement? serverParams) case "crash": Crashed?.Invoke(this, EventArgs.Empty); break; - case "domcontentloaded": - DOMContentLoaded?.Invoke(this, EventArgs.Empty); - break; - case "load": - Load?.Invoke(this, EventArgs.Empty); - break; case "bindingCall": BindingCall?.Invoke( this, diff --git a/src/Playwright/Transport/Connection.cs b/src/Playwright/Transport/Connection.cs index ba4d6c1e7f..3702636ae8 100644 --- a/src/Playwright/Transport/Connection.cs +++ b/src/Playwright/Transport/Connection.cs @@ -49,9 +49,10 @@ internal class Connection : IDisposable private int _lastId; private string _reason = string.Empty; - public Connection() + public Connection(LocalUtils localUtils = null) { _rootObject = new(null, this, string.Empty); + LocalUtils = localUtils; DefaultJsonSerializerOptions = JsonExtensions.GetNewDefaultSerializerOptions(); DefaultJsonSerializerOptions.Converters.Add(new ChannelToGuidConverter(this)); @@ -76,6 +77,8 @@ public Connection() internal bool IsRemote { get; set; } + internal LocalUtils LocalUtils { get; private set; } + internal Func OnMessage { get; set; } internal JsonSerializerOptions DefaultJsonSerializerOptions { get; } @@ -304,6 +307,10 @@ private void CreateRemoteObject(string parentGuid, ChannelOwnerType type, string break; case ChannelOwnerType.LocalUtils: result = new LocalUtils(parent, guid, initializer); + if (LocalUtils == null) + { + LocalUtils = result as LocalUtils; + } break; case ChannelOwnerType.Page: result = new Page(parent, guid, initializer?.ToObject(DefaultJsonSerializerOptions)); diff --git a/src/Playwright/Transport/Protocol/Generated/ExpectedTextValue.cs b/src/Playwright/Transport/Protocol/Generated/ExpectedTextValue.cs index 991246372d..e20b64e30b 100644 --- a/src/Playwright/Transport/Protocol/Generated/ExpectedTextValue.cs +++ b/src/Playwright/Transport/Protocol/Generated/ExpectedTextValue.cs @@ -41,6 +41,9 @@ internal class ExpectedTextValue [JsonPropertyName("matchSubstring")] public bool MatchSubstring { get; set; } + [JsonPropertyName("ignoreCase")] + public bool IgnoreCase { get; set; } + [JsonPropertyName("normalizeWhiteSpace")] public bool NormalizeWhiteSpace { get; set; } } diff --git a/src/Playwright/Transport/Protocol/Generated/RecordHarOptions.cs b/src/Playwright/Transport/Protocol/Generated/RecordHarOptions.cs new file mode 100644 index 0000000000..3b97fede08 --- /dev/null +++ b/src/Playwright/Transport/Protocol/Generated/RecordHarOptions.cs @@ -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.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Microsoft.Playwright.Transport.Protocol +{ + internal class RecordHarOptions + { + [JsonPropertyName("path")] + public string Path { get; set; } + + [JsonPropertyName("content")] + public string Content { get; set; } + + [JsonPropertyName("mode")] + public string Mode { get; set; } + + [JsonPropertyName("urlGlob")] + public string UrlGlob { get; set; } + + [JsonPropertyName("urlRegexSource")] + public string UrlRegexSource { get; set; } + + [JsonPropertyName("urlRegexFlags")] + public string UrlRegexFlags { get; set; } + } +} diff --git a/src/Playwright/Transport/Protocol/Generated/ResponseInitializer.cs b/src/Playwright/Transport/Protocol/Generated/ResponseInitializer.cs index 8b332bd489..a7f33b6111 100644 --- a/src/Playwright/Transport/Protocol/Generated/ResponseInitializer.cs +++ b/src/Playwright/Transport/Protocol/Generated/ResponseInitializer.cs @@ -46,5 +46,8 @@ internal class ResponseInitializer [JsonPropertyName("timing")] public RequestTimingResult Timing { get; set; } + + [JsonPropertyName("fromServiceWorker")] + public bool FromServiceWorker { get; set; } } }