From 4c6fccc3d280b606c439aafc761ee7f4e8f46f38 Mon Sep 17 00:00:00 2001
From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Date: Tue, 3 Aug 2021 18:57:17 +0530
Subject: [PATCH] chore: remove c# comments (#168)
---
generated_interfaces.go | 843 ---------------------------------
scripts/generate-interfaces.js | 2 +-
2 files changed, 1 insertion(+), 844 deletions(-)
diff --git a/generated_interfaces.go b/generated_interfaces.go
index c1b107c..8caf756 100644
--- a/generated_interfaces.go
+++ b/generated_interfaces.go
@@ -5,22 +5,6 @@ type BindingCall interface {
}
// A Browser is created via BrowserType.launch(). An example of using a `Browser` to create a `Page`:
-// ```csharp
-// using Microsoft.Playwright;
-// using System.Threading.Tasks;
-// class Program
-// {
-// public static async Task Main()
-// {
-// using var playwright = await Playwright.CreateAsync();
-// var firefox = playwright.Firefox;
-// var browser = await firefox.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
-// var page = await browser.NewPageAsync();
-// await page.GotoAsync("https://www.bing.com");
-// await browser.CloseAsync();
-// }
-// }
-// ```
type Browser interface {
EventEmitter
// In case this browser is obtained using BrowserType.launch(), closes the browser and all of its pages (if any
@@ -30,26 +14,10 @@ type Browser interface {
// The `Browser` object itself is considered to be disposed and cannot be used anymore.
Close() error
// Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
- // ```csharp
- // using var playwright = await Playwright.CreateAsync();
- // var browser = await playwright.Webkit.LaunchAsync();
- // System.Console.WriteLine(browser.Contexts.Count); // prints "0"
- // var context = await browser.NewContextAsync();
- // System.Console.WriteLine(browser.Contexts.Count); // prints "1"
- // ```
Contexts() []BrowserContext
// Indicates that the browser is connected.
IsConnected() bool
// Creates a new browser context. It won't share cookies/cache with other browser contexts.
- // ```csharp
- // using var playwright = await Playwright.CreateAsync();
- // var browser = await playwright.Firefox.LaunchAsync();
- // // Create a new incognito browser context.
- // var context = await browser.NewContextAsync();
- // // Create a new page in a pristine context.
- // var page = await context.NewPageAsync(); ;
- // await page.GotoAsync("https://www.bing.com");
- // ```
NewContext(options ...BrowserNewContextOptions) (BrowserContext, error)
// Creates a new page in a new browser context. Closing this page will close the context as well.
// This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
@@ -84,24 +52,10 @@ type CDPSession interface {
// context.
// Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser
// contexts don't write any browsing data to disk.
-// ```csharp
-// using var playwright = await Playwright.CreateAsync();
-// var browser = await playwright.Firefox.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
-// // Create a new incognito browser context
-// var context = await browser.NewContextAsync();
-// // Create a new page inside context.
-// var page = await context.NewPageAsync();
-// await page.GotoAsync("https://bing.com");
-// // Dispose context once it is no longer needed.
-// await context.CloseAsync();
-// ```
type BrowserContext interface {
EventEmitter
// Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
// obtained via BrowserContext.cookies().
- // ```csharp
- // await context.AddCookiesAsync(new[] { cookie1, cookie2 });
- // ```
AddCookies(cookies ...SetNetworkCookieParam) error
// Adds a script which would be evaluated in one of the following scenarios:
// - Whenever a page is created in the browser context or is navigated.
@@ -110,9 +64,6 @@ type BrowserContext interface {
// The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
// the JavaScript environment, e.g. to seed `Math.random`.
// An example of overriding `Math.random` before the page loads:
- // ```csharp
- // await context.AddInitScriptAsync(new BrowserContextAddInitScriptOptions { ScriptPath = "preload.js" });
- // ```
// > NOTE: The order of evaluation of multiple scripts installed via BrowserContext.addInitScript() and
// Page.addInitScript() is not defined.
AddInitScript(script BrowserContextAddInitScriptOptions) error
@@ -121,14 +72,6 @@ type BrowserContext interface {
// Clears context cookies.
ClearCookies() error
// Clears all permission overrides for the browser context.
- // ```csharp
- // var context = await browser.NewContextAsync();
- // await context.GrantPermissionsAsync(new[] { "clipboard-read" });
- // // Alternatively, you can use the helper class ContextPermissions
- // // to specify the permissions...
- // // do stuff ...
- // await context.ClearPermissionsAsync();
- // ```
ClearPermissions() error
// Closes the browser context. All the pages that belong to the browser context will be closed.
// > NOTE: The default browser context cannot be closed.
@@ -144,83 +87,13 @@ type BrowserContext interface {
// page: Page, frame: Frame }`.
// See Page.exposeBinding() for page-only version.
// An example of exposing page URL to all frames in all pages in the context:
- // ```csharp
- // using Microsoft.Playwright;
- // using System.Threading.Tasks;
- // class Program
- // {
- // public static async Task Main()
- // {
- // using var playwright = await Playwright.CreateAsync();
- // var browser = await playwright.Webkit.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
- // var context = await browser.NewContextAsync();
- // await context.ExposeBindingAsync("pageURL", source => source.Page.Url);
- // var page = await context.NewPageAsync();
- // await page.SetContentAsync("\n" +
- // "\n" +
- // "
");
- // await page.ClickAsync("button");
- // }
- // }
- // ```
// An example of passing an element handle:
- // ```csharp
- // var result = new TaskCompletionSource();
- // var page = await Context.NewPageAsync();
- // await Context.ExposeBindingAsync("clicked", async (BindingSource _, IJSHandle t) =>
- // {
- // return result.TrySetResult(await t.AsElement().TextContentAsync());
- // });
- // await page.SetContentAsync("\n" +
- // "
Click me
\n" +
- // "
Or click me
\n");
- // await page.ClickAsync("div");
- // // Note: it makes sense to await the result here, because otherwise, the context
- // // gets closed and the binding function will throw an exception.
- // Assert.Equal("Click me", await result.Task);
- // ```
ExposeBinding(name string, binding BindingCallFunction, handle ...bool) error
// The method adds a function called `name` on the `window` object of every frame in every page in the context. When
// called, the function executes `callback` and returns a [Promise] which resolves to the return value of `callback`.
// If the `callback` returns a [Promise], it will be awaited.
// See Page.exposeFunction() for page-only version.
// An example of adding a `sha256` function to all pages in the context:
- // ```csharp
- // using Microsoft.Playwright;
- // using System;
- // using System.Security.Cryptography;
- // using System.Threading.Tasks;
- // class BrowserContextExamples
- // {
- // public static async Task Main()
- // {
- // using var playwright = await Playwright.CreateAsync();
- // var browser = await playwright.Webkit.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
- // var context = await browser.NewContextAsync();
- // await context.ExposeFunctionAsync("sha256", (string input) =>
- // {
- // return Convert.ToBase64String(
- // SHA256.Create().ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));
- // });
- // var page = await context.NewPageAsync();
- // await page.SetContentAsync("\n" +
- // "\n" +
- // "");
- // await page.ClickAsync("button");
- // Console.WriteLine(await page.TextContentAsync("div"));
- // }
- // }
- // ```
ExposeFunction(name string, binding ExposedFunction) error
// Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
// specified.
@@ -252,13 +125,6 @@ type BrowserContext interface {
// > NOTE: BrowserContext.setExtraHTTPHeaders() does not guarantee the order of headers in the outgoing requests.
SetExtraHTTPHeaders(headers map[string]string) error
// Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.
- // ```csharp
- // await context.SetGeolocationAsync(new Geolocation()
- // {
- // Latitude = 59.95f,
- // Longitude = 30.31667f
- // });
- // ```
// > NOTE: Consider using BrowserContext.grantPermissions() to grant permissions for the browser context pages to
// read its geolocation.
SetGeolocation(gelocation *SetGeolocationOptions) error
@@ -266,32 +132,9 @@ type BrowserContext interface {
// Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
// is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
// An example of a naive handler that aborts all image requests:
- // ```csharp
- // var context = await browser.NewContextAsync();
- // var page = await context.NewPageAsync();
- // await context.RouteAsync("**/*.{png,jpg,jpeg}", r => r.AbortAsync());
- // await page.GotoAsync("https://theverge.com");
- // await browser.CloseAsync();
- // ```
// or the same snippet using a regex pattern instead:
- // ```csharp
- // var context = await browser.NewContextAsync();
- // var page = await context.NewPageAsync();
- // await context.RouteAsync(new Regex("(\\.png$)|(\\.jpg$)"), r => r.AbortAsync());
- // await page.GotoAsync("https://theverge.com");
- // await browser.CloseAsync();
- // ```
// It is possible to examine the request to decide the route action. For example, mocking all requests that contain some
// post data, and leaving all other requests as is:
- // ```csharp
- // await page.RouteAsync("/api/**", async r =>
- // {
- // if (r.Request.PostData.Contains("my-string"))
- // await r.FulfillAsync(body: "mocked-data");
- // else
- // await r.ContinueAsync();
- // });
- // ```
// Page routes (set up with Page.route()) take precedence over browser context routes when request matches both
// handlers.
// To remove a route with its handler you can use BrowserContext.unroute().
@@ -305,44 +148,16 @@ type BrowserContext interface {
Unroute(url interface{}, handler ...routeHandler) error
// Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
// value. Will throw an error if the context closes before the event is fired. Returns the event data value.
- // ```csharp
- // var page = await context.RunAndWaitForPageAsync(async () =>
- // {
- // await page.ClickAsync("button");
- // });
- // ```
WaitForEvent(event string, predicate ...interface{}) interface{}
}
// BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
// typical example of using Playwright to drive automation:
-// ```csharp
-// using Microsoft.Playwright;
-// using System.Threading.Tasks;
-// class BrowserTypeExamples
-// {
-// public static async Task Run()
-// {
-// using var playwright = await Playwright.CreateAsync();
-// var chromium = playwright.Chromium;
-// var browser = await chromium.LaunchAsync();
-// var page = await browser.NewPageAsync();
-// await page.GoToAsync("https://www.bing.com");
-// // other actions
-// await browser.CloseAsync();
-// }
-// }
-// ```
type BrowserType interface {
// A path where Playwright expects to find a bundled browser executable.
ExecutablePath() string
// Returns the browser instance.
// You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
- // ```csharp
- // var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions {
- // IgnoreDefaultArgs = new[] { "--mute-audio" }
- // })
- // ```
// > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works
// best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
// `executablePath` option with extreme caution.
@@ -382,25 +197,6 @@ type ConsoleMessage interface {
// `Dialog` objects are dispatched by page via the [`event: Page.dialog`] event.
// An example of using `Dialog` class:
-// ```csharp
-// using Microsoft.Playwright;
-// using System.Threading.Tasks;
-// class DialogExample
-// {
-// public static async Task Run()
-// {
-// using var playwright = await Playwright.CreateAsync();
-// await using var browser = await playwright.Chromium.LaunchAsync();
-// var page = await browser.NewPageAsync();
-// page.Dialog += async (_, dialog) =>
-// {
-// System.Console.WriteLine(dialog.Message);
-// await dialog.DismissAsync();
-// };
-// await page.EvaluateAsync("alert('1');");
-// }
-// }
-// ```
// > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is
// present, it **must** either Dialog.accept`] or [`method: Dialog.dismiss() the dialog - otherwise the page will
// [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and
@@ -421,13 +217,6 @@ type Dialog interface {
// `Download` objects are dispatched by page via the [`event: Page.download`] event.
// All the downloaded files belonging to the browser context are deleted when the browser context is closed.
// Download event is emitted once the download starts. Download path becomes available once download completes:
-// ```csharp
-// var download = await page.RunAndWaitForDownloadAsync(async () =>
-// {
-// await page.ClickAsync("#downloadButton");
-// });
-// Console.WriteLine(await download.PathAsync());
-// ```
// > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
// downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
// performed and user has no access to the downloaded files.
@@ -456,22 +245,6 @@ type Download interface {
// ElementHandle represents an in-page DOM element. ElementHandles can be created with the Page.querySelector()
// method.
-// ```csharp
-// using Microsoft.Playwright;
-// using System.Threading.Tasks;
-// class HandleExamples
-// {
-// public static async Task Run()
-// {
-// using var playwright = await Playwright.CreateAsync();
-// var browser = await playwright.Chromium.LaunchAsync();
-// var page = await browser.NewPageAsync();
-// await page.GotoAsync("https://www.bing.com");
-// var handle = await page.QuerySelectorAsync("a");
-// await handle.ClickAsync();
-// }
-// }
-// ```
// ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
// JSHandle.dispose(). ElementHandles are auto-disposed when their origin frame gets navigated.
// ElementHandle instances can be used as an argument in Page.evalOnSelector`] and [`method: Page.evaluate()
@@ -487,10 +260,6 @@ type ElementHandle interface {
// [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
// Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
// snippet should click the center of the element.
- // ```csharp
- // var box = await elementHandle.BoundingBoxAsync();
- // await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
- // ```
BoundingBox() (*Rect, error)
// This method checks the element by performing the following steps:
// 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked,
@@ -529,9 +298,6 @@ type ElementHandle interface {
// The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
// `click` is dispatched. This is equivalent to calling
// [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
- // ```csharp
- // await elementHandle.DispatchEventAsync("click");
- // ```
// Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
// and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
// Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
@@ -543,13 +309,6 @@ type ElementHandle interface {
// - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
// - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
// You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
- // ```csharp
- // var handle = await page.EvaluateHandleAsync("() => new DataTransfer()");
- // await handle.AsElement().DispatchEventAsync("dragstart", new Dictionary
- // {
- // { "dataTransfer", dataTransfer }
- // });
- // ```
DispatchEvent(typ string, initObjects ...interface{}) error
// Returns the return value of `expression`.
// The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
@@ -558,11 +317,6 @@ type ElementHandle interface {
// If `expression` returns a [Promise], then ElementHandle.evalOnSelector() would wait for the promise to resolve
// and return its value.
// Examples:
- // ```csharp
- // var tweetHandle = await page.QuerySelectorAsync(".tweet");
- // Assert.Equals("100", await tweetHandle.EvalOnSelectorAsync(".like", "node => node.innerText"));
- // Assert.Equals("10", await tweetHandle.EvalOnSelectorAsync(".retweets", "node => node.innerText"));
- // ```
EvalOnSelector(selector string, expression string, options ...interface{}) (interface{}, error)
// Returns the return value of `expression`.
// The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
@@ -576,10 +330,6 @@ type ElementHandle interface {
//
Hi!
//
// ```
- // ```csharp
- // var feedHandle = await page.QuerySelectorAsync(".feed");
- // Assert.Equals(new [] { "Hello!", "Hi!" }, await feedHandle.EvalOnSelectorAllAsync(".tweet", "nodes => nodes.map(n => n.innerText)"));
- // ```
EvalOnSelectorAll(selector string, expression string, options ...interface{}) (interface{}, error)
// This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input`
// event after filling. Note that you can pass an empty string to clear the input field.
@@ -656,19 +406,6 @@ type ElementHandle interface {
// [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
// Returns the array of option values that have been successfully selected.
// Triggers a `change` and `input` event once all the provided options have been selected.
- // ```csharp
- // // single selection matching the value
- // await handle.SelectOptionAsync(new[] { "blue" });
- // // single selection matching the label
- // await handle.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
- // // multiple selection
- // await handle.SelectOptionAsync(new[] { "red", "green", "blue" });
- // // multiple selection for blue, red and second option
- // await handle.SelectOptionAsync(new[] {
- // new SelectOptionValue() { Label = "blue" },
- // new SelectOptionValue() { Index = 2 },
- // new SelectOptionValue() { Value = "red" }});
- // ```
SelectOption(values SelectOptionValues, options ...ElementHandleSelectOptionOptions) ([]string, error)
// This method waits for [actionability](./actionability.md) checks, then focuses the element and selects all its text
// content.
@@ -692,16 +429,7 @@ type ElementHandle interface {
TextContent() (string, error)
// Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
// To press a special key, like `Control` or `ArrowDown`, use ElementHandle.press().
- // ```csharp
- // await elementHandle.TypeAsync("Hello"); // Types instantly
- // await elementHandle.TypeAsync("World", delay: 100); // Types slower, like a user
- // ```
// An example of typing into a text field and then submitting the form:
- // ```csharp
- // var elementHandle = await page.QuerySelectorAsync("input");
- // await elementHandle.TypeAsync("some text");
- // await elementHandle.PressAsync("Enter");
- // ```
Type(value string, options ...ElementHandleTypeOptions) error
// This method checks the element by performing the following steps:
// 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already
@@ -734,12 +462,6 @@ type ElementHandle interface {
// become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
// will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will
// throw.
- // ```csharp
- // await page.SetContentAsync("
");
- // var div = await page.QuerySelectorAsync("div");
- // // Waiting for the "span" selector relative to the div.
- // var span = await page.WaitForSelectorAsync("span", WaitForSelectorState.Attached);
- // ```
// > NOTE: This method does not work across navigations, use Page.waitForSelector() instead.
WaitForSelector(selector string, options ...ElementHandleWaitForSelectorOptions) (ElementHandle, error)
}
@@ -753,13 +475,6 @@ type EventEmitter interface {
}
// `FileChooser` objects are dispatched by the page in the [`event: Page.fileChooser`] event.
-// ```csharp
-// var fileChooser = await page.RunAndWaitForFileChooserAsync(async () =>
-// {
-// await page.ClickAsync("upload");
-// });
-// await fileChooser.SetFilesAsync("temp.txt");
-// ```
type FileChooser interface {
// Returns input element associated with this file chooser.
Element() ElementHandle
@@ -781,28 +496,6 @@ type FileChooser interface {
// - [`event: Page.frameDetached`] - fired when the frame gets detached from the page. A Frame can be detached from the
// page only once.
// An example of dumping frame tree:
-// ```csharp
-// using Microsoft.Playwright;
-// using System;
-// using System.Threading.Tasks;
-// class FrameExamples
-// {
-// public static async Task Main()
-// {
-// using var playwright = await Playwright.CreateAsync();
-// await using var browser = await playwright.Firefox.LaunchAsync();
-// var page = await browser.NewPageAsync();
-// await page.GotoAsync("https://www.bing.com");
-// DumpFrameTree(page.MainFrame, string.Empty);
-// }
-// private static void DumpFrameTree(IFrame frame, string indent)
-// {
-// Console.WriteLine($"{indent}{frame.Url}");
-// foreach (var child in frame.ChildFrames)
-// DumpFrameTree(child, indent + " ");
-// }
-// }
-// ```
type Frame interface {
// Returns the added tag when the script's onload fires or when the script content was injected into frame.
// Adds a `\n" +
- // "\n" +
- // "");
- // await page.ClickAsync("button");
- // }
- // }
- // ```
// An example of passing an element handle:
- // ```csharp
- // var result = new TaskCompletionSource();
- // await page.ExposeBindingAsync("clicked", async (BindingSource _, IJSHandle t) =>
- // {
- // return result.TrySetResult(await t.AsElement().TextContentAsync());
- // });
- // await page.SetContentAsync("\n" +
- // "
Click me
\n" +
- // "
Or click me
\n");
- // await page.ClickAsync("div");
- // Console.WriteLine(await result.Task);
- // ```
ExposeBinding(name string, binding BindingCallFunction, handle ...bool) error
// The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
// executes `callback` and returns a [Promise] which resolves to the return value of `callback`.
@@ -1527,66 +975,9 @@ type Page interface {
// See BrowserContext.exposeFunction() for context-wide exposed function.
// > NOTE: Functions installed via Page.exposeFunction() survive navigations.
// An example of adding a `sha256` function to the page:
- // ```csharp
- // using Microsoft.Playwright;
- // using System;
- // using System.Security.Cryptography;
- // using System.Threading.Tasks;
- // class PageExamples
- // {
- // public static async Task Main()
- // {
- // using var playwright = await Playwright.CreateAsync();
- // await using var browser = await playwright.Webkit.LaunchAsync(new BrowserTypeLaunchOptions
- // {
- // Headless: false
- // });
- // var page = await browser.NewPageAsync();
- // await page.ExposeFunctionAsync("sha256", (string input) =>
- // {
- // return Convert.ToBase64String(
- // SHA256.Create().ComputeHash(System.Text.Encoding.UTF8.GetBytes(input)));
- // });
- // await page.SetContentAsync("\n" +
- // "\n" +
- // "");
- // await page.ClickAsync("button");
- // Console.WriteLine(await page.TextContentAsync("div"));
- // }
- // }
- // ```
ExposeFunction(name string, binding ExposedFunction) error
// This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
// feature, using the `colorScheme` argument.
- // ```csharp
- // await page.EvaluateAsync("() => matchMedia('screen').matches");
- // // → true
- // await page.EvaluateAsync("() => matchMedia('print').matches");
- // // → false
- // await page.EmulateMediaAsync(new PageEmulateMediaOptions { Media = Media.Print });
- // await page.EvaluateAsync("() => matchMedia('screen').matches");
- // // → false
- // await page.EvaluateAsync("() => matchMedia('print').matches");
- // // → true
- // await page.EmulateMediaAsync(new PageEmulateMediaOptions { Media = Media.Screen });
- // await page.EvaluateAsync("() => matchMedia('screen').matches");
- // // → true
- // await page.EvaluateAsync("() => matchMedia('print').matches");
- // // → false
- // ```
- // ```csharp
- // await page.EmulateMediaAsync(new PageEmulateMediaOptions { ColorScheme = ColorScheme.Dark });
- // await page.EvaluateAsync("matchMedia('(prefers-color-scheme: dark)').matches");
- // // → true
- // await page.EvaluateAsync("matchMedia('(prefers-color-scheme: light)').matches");
- // // → false
- // await page.EvaluateAsync("matchMedia('(prefers-color-scheme: no-preference)').matches");
- // // → false
- // ```
EmulateMedia(options ...PageEmulateMediaOptions) error
// Returns the value of the `expression` invocation.
// If the function passed to the Page.evaluate`] returns a [Promise], then [`method: Page.evaluate() would wait
@@ -1595,20 +986,8 @@ type Page interface {
// Page.evaluate() resolves to `undefined`. Playwright also supports transferring some additional values that are
// not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
// Passing argument to `expression`:
- // ```csharp
- // var result = await page.EvaluateAsync("([x, y]) => Promise.resolve(x * y)", new[] { 7, 8 });
- // Console.WriteLine(result);
- // ```
// A string can also be passed in instead of a function:
- // ```csharp
- // Console.WriteLine(await page.EvaluateAsync("1 + 2")); // prints "3"
- // ```
// `ElementHandle` instances can be passed as an argument to the Page.evaluate():
- // ```csharp
- // var bodyHandle = await page.QuerySelectorAsync("body");
- // var html = await page.EvaluateAsync("([body, suffix]) => body.innerHTML + suffix", new object [] { bodyHandle, "hello" });
- // await bodyHandle.DisposeAsync();
- // ```
// Shortcut for main frame's Frame.evaluate().
Evaluate(expression string, options ...interface{}) (interface{}, error)
// Returns the value of the `expression` invocation as a `JSHandle`.
@@ -1616,32 +995,14 @@ type Page interface {
// Page.evaluateHandle() returns `JSHandle`.
// If the function passed to the Page.evaluateHandle`] returns a [Promise], then [`method: Page.evaluateHandle()
// would wait for the promise to resolve and return its value.
- // ```csharp
- // // Handle for the window object.
- // var aWindowHandle = await page.EvaluateHandleAsync("() => Promise.resolve(window)");
- // ```
// A string can also be passed in instead of a function:
- // ```csharp
- // var docHandle = await page.EvalueHandleAsync("document"); // Handle for the `document`
- // ```
// `JSHandle` instances can be passed as an argument to the Page.evaluateHandle():
- // ```csharp
- // var handle = await page.EvaluateHandleAsync("() => document.body");
- // var resultHandle = await page.EvaluateHandleAsync("([body, suffix]) => body.innerHTML + suffix", new object[] { handle, "hello" });
- // Console.WriteLine(await resultHandle.JsonValueAsync());
- // await resultHandle.DisposeAsync();
- // ```
EvaluateHandle(expression string, options ...interface{}) (JSHandle, error)
// The method finds an element matching the specified selector within the page and passes it as a first argument to
// `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
// If `expression` returns a [Promise], then Page.evalOnSelector() would wait for the promise to resolve and
// return its value.
// Examples:
- // ```csharp
- // var searchValue = await page.EvalOnSelectorAsync("#search", "el => el.value");
- // var preloadHref = await page.EvalOnSelectorAsync("link[rel=preload]", "el => el.href");
- // var html = await page.EvalOnSelectorAsync(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
- // ```
// Shortcut for main frame's Frame.evalOnSelector().
EvalOnSelector(selector string, expression string, options ...interface{}) (interface{}, error)
// The method finds all elements matching the specified selector within the page and passes an array of matched elements as
@@ -1649,9 +1010,6 @@ type Page interface {
// If `expression` returns a [Promise], then Page.evalOnSelectorAll() would wait for the promise to resolve and
// return its value.
// Examples:
- // ```csharp
- // var divsCount = await page.EvalOnSelectorAllAsync("div", "(divs, min) => divs.length >= min", 10);
- // ```
EvalOnSelectorAll(selector string, expression string, options ...interface{}) (interface{}, error)
ExpectConsoleMessage(cb func() error) (ConsoleMessage, error)
ExpectDownload(cb func() error) (Download, error)
@@ -1679,12 +1037,6 @@ type Page interface {
// Shortcut for main frame's Frame.focus().
Focus(expression string, options ...FrameFocusOptions) error
// Returns frame matching the specified criteria. Either `name` or `url` must be specified.
- // ```csharp
- // var frame = page.Frame("frame-name");
- // ```
- // ```csharp
- // var frame = page.FrameByUrl(".*domain.*");
- // ```
Frame(options PageFrameOptions) Frame
// An array of all frames attached to the page.
Frames() []Frame
@@ -1757,11 +1109,6 @@ type Page interface {
// > NOTE: By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
// [`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
// force rendering of exact colors.
- // ```csharp
- // // Generates a PDF with 'screen' media type
- // await page.EmulateMediaAsync(new PageEmulateMediaOptions { Media = Media.Screen });
- // await page.PdfAsync(new PagePdfOptions { Path = "page.pdf" });
- // ```
// The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels.
// A few examples:
// - `page.pdf({width: 100})` - prints with width set to 100 pixels
@@ -1799,16 +1146,6 @@ type Page interface {
// texts.
// Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
// modifier, modifier is pressed and being held while the subsequent key is being pressed.
- // ```csharp
- // var page = await browser.NewPageAsync();
- // await page.GotoAsync("https://keycode.info");
- // await page.PressAsync("body", "A");
- // await page.ScreenshotAsync(new PageScreenshotOptions { Path = "A.png" });
- // await page.PressAsync("body", "ArrowLeft");
- // await page.ScreenshotAsync(new PageScreenshotOptions { Path = "ArrowLeft.png" });
- // await page.PressAsync("body", "Shift+O");
- // await page.ScreenshotAsync(new PageScreenshotOptions { Path = "O.png" });
- // ```
Press(selector, key string, options ...PagePressOptions) error
// The method finds an element matching the specified selector within the page. If no elements match the selector, the
// return value resolves to `null`. To wait for an element on the page, use Page.waitForSelector().
@@ -1825,28 +1162,9 @@ type Page interface {
// Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
// > NOTE: The handler will only be called for the first url if the response is a redirect.
// An example of a naive handler that aborts all image requests:
- // ```csharp
- // var page = await browser.NewPageAsync();
- // await page.RouteAsync("**/*.{png,jpg,jpeg}", async r => await r.AbortAsync());
- // await page.GotoAsync("https://www.microsoft.com");
- // ```
// or the same snippet using a regex pattern instead:
- // ```csharp
- // var page = await browser.NewPageAsync();
- // await page.RouteAsync(new Regex("(\\.png$)|(\\.jpg$)"), async r => await r.AbortAsync());
- // await page.GotoAsync("https://www.microsoft.com");
- // ```
// It is possible to examine the request to decide the route action. For example, mocking all requests that contain some
// post data, and leaving all other requests as is:
- // ```csharp
- // await page.RouteAsync("/api/**", async r =>
- // {
- // if (r.Request.PostData.Contains("my-string"))
- // await r.FulfillAsync(new RouteFulfillOptions { Body = "mocked-data" });
- // else
- // await r.ContinueAsync();
- // });
- // ```
// Page routes take precedence over browser context routes (set up with BrowserContext.route()) when request
// matches both handlers.
// To remove a route with its handler you can use Page.unroute().
@@ -1861,14 +1179,6 @@ type Page interface {
// [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
// Returns the array of option values that have been successfully selected.
// Triggers a `change` and `input` event once all the provided options have been selected.
- // ```csharp
- // // single selection matching the value
- // await page.SelectOptionAsync("select#colors", new[] { "blue" });
- // // single selection matching both the value and the label
- // await page.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });
- // // multiple
- // await page.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
- // ```
// Shortcut for main frame's Frame.selectOption().
SelectOption(selector string, values SelectOptionValues, options ...FrameSelectOptionOptions) ([]string, error)
SetContent(content string, options ...PageSetContentOptions) error
@@ -1898,11 +1208,6 @@ type Page interface {
// Browser.newContext() allows to set viewport size (and more) for all pages in the context at once.
// `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
// viewport size before navigating to the page.
- // ```csharp
- // var page = await browser.NewPageAsync();
- // await page.SetViewportSizeAsync(640, 480);
- // await page.GotoAsync("https://www.microsoft.com");
- // ```
SetViewportSize(width, height int) error
// This method taps an element matching `selector` by performing the following steps:
// 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
@@ -1923,10 +1228,6 @@ type Page interface {
// Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send
// fine-grained keyboard events. To fill values in form fields, use Page.fill().
// To press a special key, like `Control` or `ArrowDown`, use Keyboard.press().
- // ```csharp
- // await page.TypeAsync("#mytextarea", "hello"); // types instantly
- // await page.TypeAsync("#mytextarea", "world"); // types slower, like a user
- // ```
// Shortcut for main frame's Frame.type().
Type(selector, text string, options ...PageTypeOptions) error
// Shortcut for main frame's Frame.url().
@@ -1955,43 +1256,12 @@ type Page interface {
WaitForEvent(event string, predicate ...interface{}) interface{}
// Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
// The Page.waitForFunction() can be used to observe viewport size change:
- // ```csharp
- // using Microsoft.Playwright;
- // using System.Threading.Tasks;
- // class FrameExamples
- // {
- // public static async Task WaitForFunction()
- // {
- // using var playwright = await Playwright.CreateAsync();
- // await using var browser = await playwright.Webkit.LaunchAsync();
- // var page = await browser.NewPageAsync();
- // await page.SetViewportSizeAsync(50, 50);
- // await page.MainFrame.WaitForFunctionAsync("window.innerWidth < 100");
- // }
- // }
- // ```
// To pass an argument to the predicate of Page.waitForFunction() function:
- // ```csharp
- // var selector = ".foo";
- // await page.WaitForFunctionAsync("selector => !!document.querySelector(selector)", selector);
- // ```
// Shortcut for main frame's Frame.waitForFunction().
WaitForFunction(expression string, arg interface{}, options ...FrameWaitForFunctionOptions) (JSHandle, error)
// Returns when the required load state has been reached.
// This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed
// when this method is called. If current document has already reached the required state, resolves immediately.
- // ```csharp
- // await page.ClickAsync("button"); // Click triggers navigation.
- // await page.WaitForLoadStateAsync(); // The promise resolves after 'load' event.
- // ```
- // ```csharp
- // var popup = await page.RunAndWaitForPopupAsync(async () =>
- // {
- // await page.ClickAsync("button"); // click triggers the popup/
- // });
- // await popup.WaitForLoadStateAsync(LoadState.DOMContentLoaded);
- // Console.WriteLine(await popup.TitleAsync()); // popup is ready to use.
- // ```
// Shortcut for main frame's Frame.waitForLoadState().
WaitForLoadState(state ...string)
// Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the
@@ -2000,46 +1270,14 @@ type Page interface {
// This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
// cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
// Consider this example:
- // ```csharp
- // await page.RunAndWaitForNavigationAsync(async () =>
- // {
- // // Clicking the link will indirectly cause a navigation.
- // await page.ClickAsync("a.delayed-navigation");
- // });
- // // The method continues after navigation has finished
- // ```
// > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
// considered a navigation.
// Shortcut for main frame's Frame.waitForNavigation().
WaitForNavigation(options ...PageWaitForNavigationOptions) (Response, error)
// Waits for the matching request and returns it. See [waiting for event](./events.md#waiting-for-event) for more details
// about events.
- // ```csharp
- // // Waits for the next request with the specified url.
- // await page.RunAndWaitForRequestAsync(async () =>
- // {
- // await page.ClickAsync("button");
- // }, "http://example.com/resource");
- // // Alternative way with a predicate.
- // await page.RunAndWaitForRequestAsync(async () =>
- // {
- // await page.ClickAsync("button");
- // }, request => request.Url == "https://example.com" && request.Method == "GET");
- // ```
WaitForRequest(url interface{}, options ...interface{}) Request
// Returns the matched response. See [waiting for event](./events.md#waiting-for-event) for more details about events.
- // ```csharp
- // // Waits for the next response with the specified url.
- // await page.RunAndWaitForResponseAsync(async () =>
- // {
- // await page.ClickAsync("button.triggers-response");
- // }, "http://example.com/resource");
- // // Alternative way with a predicate.
- // await page.RunAndWaitForResponseAsync(async () =>
- // {
- // await page.ClickAsync("button");
- // }, response => response.Url == "https://example.com" && response.Status == 200);
- // ```
WaitForResponse(url interface{}, options ...interface{}) Response
// Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
// `detached`.
@@ -2047,35 +1285,10 @@ type Page interface {
// the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
// selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
// This method works across navigations:
- // ```csharp
- // using Microsoft.Playwright;
- // using System;
- // using System.Threading.Tasks;
- // class FrameExamples
- // {
- // public static async Task Images()
- // {
- // using var playwright = await Playwright.CreateAsync();
- // await using var browser = await playwright.Chromium.LaunchAsync();
- // var page = await browser.NewPageAsync();
- // foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
- // {
- // await page.GotoAsync(currentUrl);
- // var element = await page.WaitForSelectorAsync("img");
- // Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
- // }
- // await browser.CloseAsync();
- // }
- // }
- // ```
WaitForSelector(selector string, options ...PageWaitForSelectorOptions) (ElementHandle, error)
// Waits for the given `timeout` in milliseconds.
// Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be
// flaky. Use signals such as network events, selectors becoming visible and others instead.
- // ```csharp
- // // Wait for 1 second
- // await page.WaitForTimeoutAsync(1000);
- // ```
// Shortcut for main frame's Frame.waitForTimeout().
WaitForTimeout(timeout float64)
// This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
@@ -2097,12 +1310,6 @@ type Page interface {
type Request interface {
// The method returns `null` unless this request has failed, as reported by `requestfailed` event.
// Example of logging of all the failed requests:
- // ```csharp
- // page.RequestFailed += (_, request) =>
- // {
- // Console.WriteLine(request.Failure);
- // };
- // ```
Failure() *RequestFailure
// Returns the `Frame` that initiated this request.
Frame() Frame
@@ -2125,21 +1332,10 @@ type Request interface {
// `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
// construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
// For example, if the website `http://example.com` redirects to `https://example.com`:
- // ```csharp
- // var response = await page.GotoAsync("http://www.microsoft.com");
- // Console.WriteLine(response.Request.RedirectedFrom?.Url); // http://www.microsoft.com
- // ```
// If the website `https://google.com` has no redirects:
- // ```csharp
- // var response = await page.GotoAsync("https://www.google.com");
- // Console.WriteLine(response.Request.RedirectedFrom?.Url); // null
- // ```
RedirectedFrom() Request
// New request issued by the browser if the server responded with redirect.
// This method is the opposite of Request.redirectedFrom():
- // ```csharp
- // Console.WriteLine(request.RedirectedFrom?.RedirectedTo == request); // True
- // ```
RedirectedTo() Request
// Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
// following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
@@ -2150,13 +1346,6 @@ type Request interface {
// Returns resource timing information for given request. Most of the timing values become available upon the response,
// `responseEnd` becomes available when request finishes. Find more information at
// [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
- // ```csharp
- // var request = await page.RunAndWaitForRequestFinishedAsync(async () =>
- // {
- // await page.GotoAsync("https://www.microsoft.com");
- // });
- // Console.WriteLine(request.Timing.ResponseEnd);
- // ```
Timing() *ResourceTiming
// URL of the request.
URL() string
@@ -2195,27 +1384,10 @@ type Route interface {
// Aborts the route's request.
Abort(errorCode ...string) error
// Continues route's request with optional overrides.
- // ```csharp
- // await page.RouteAsync("**/*", route =>
- // {
- // var headers = new Dictionary(route.Request.Headers) { { "foo", "bar" } };
- // headers.Remove("origin");
- // route.ContinueAsync(headers);
- // });
- // ```
Continue(options ...RouteContinueOptions) error
// Fulfills route's request with given response.
// An example of fulfilling all requests with 404 responses:
- // ```csharp
- // await page.RouteAsync("**/*", route => route.FulfillAsync(
- // status: 404,
- // contentType: "text/plain",
- // body: "Not Found!"));
- // ```
// An example of serving static file:
- // ```csharp
- // await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(new RouteFulfillOptions { Path = "mock_data.json" }));
- // ```
Fulfill(options RouteFulfillOptions) error
// A request to be routed.
Request() Request
@@ -2241,9 +1413,6 @@ type WebSocket interface {
}
// When browser context is created with the `recordVideo` option, each page has a video object associated with it.
-// ```csharp
-// Console.WriteLine(await page.Video.GetPathAsync());
-// ```
type Video interface {
// Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
// upon closing the browser context. This method throws when connected remotely.
@@ -2258,18 +1427,6 @@ type Video interface {
// The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
// event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
// worker is gone.
-// ```csharp
-// page.Worker += (_, worker) =>
-// {
-// Console.WriteLine($"Worker created: {worker.Url}");
-// worker.Close += (_, _) => Console.WriteLine($"Worker closed {worker.Url}");
-// };
-// Console.WriteLine("Current Workers:");
-// foreach(var pageWorker in page.Workers)
-// {
-// Console.WriteLine($"\tWorker: {pageWorker.Url}");
-// }
-// ```
type Worker interface {
EventEmitter
// Returns the return value of `expression`.
diff --git a/scripts/generate-interfaces.js b/scripts/generate-interfaces.js
index c854844..9cae2d2 100644
--- a/scripts/generate-interfaces.js
+++ b/scripts/generate-interfaces.js
@@ -31,7 +31,7 @@ const writeComment = (comment) => {
lastWasBlank = true
continue
}
- if (["js", "js browser", "py", "python sync", "python async", "java"].includes(line.trim().substr(3)) && line.trim().startsWith("```"))
+ if (["js", "js browser", "py", "python sync", "python async", "java", "csharp"].includes(line.trim().substr(3)) && line.trim().startsWith("```"))
inExample = true
if (!inExample) {
if (lastWasBlank)