mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-27 05:46:28 +03:00
docs: fix inconsistent .NET snippets (#29831)
This commit is contained in:
parent
425f737eb6
commit
d125ff4d39
@ -186,7 +186,10 @@ context.on("dialog", lambda dialog: dialog.accept())
|
||||
```
|
||||
|
||||
```csharp
|
||||
context.Dialog += (_, dialog) => dialog.AcceptAsync();
|
||||
Context.Dialog += async (_, dialog) =>
|
||||
{
|
||||
await dialog.AcceptAsync();
|
||||
};
|
||||
```
|
||||
|
||||
:::note
|
||||
@ -390,7 +393,7 @@ browser_context.add_init_script(path="preload.js")
|
||||
```
|
||||
|
||||
```csharp
|
||||
await context.AddInitScriptAsync(scriptPath: "preload.js");
|
||||
await Context.AddInitScriptAsync(scriptPath: "preload.js");
|
||||
```
|
||||
|
||||
:::note
|
||||
@ -1180,7 +1183,7 @@ context.route("/api/**", handle_route)
|
||||
await page.RouteAsync("/api/**", async r =>
|
||||
{
|
||||
if (r.Request.PostData.Contains("my-string"))
|
||||
await r.FulfillAsync(body: "mocked-data");
|
||||
await r.FulfillAsync(new() { Body = "mocked-data" });
|
||||
else
|
||||
await r.ContinueAsync();
|
||||
});
|
||||
|
@ -608,7 +608,7 @@ page.add_init_script(path="./preload.js")
|
||||
```
|
||||
|
||||
```csharp
|
||||
await page.AddInitScriptAsync(scriptPath: "./preload.js");
|
||||
await Page.AddInitScriptAsync(scriptPath: "./preload.js");
|
||||
```
|
||||
|
||||
:::note
|
||||
|
@ -32,8 +32,11 @@ page.get_by_role("button").click()
|
||||
```
|
||||
|
||||
```csharp
|
||||
page.Dialog += (_, dialog) => dialog.AcceptAsync();
|
||||
await page.GetByRole(AriaRole.Button).ClickAsync();
|
||||
Page.Dialog += async (_, dialog) =>
|
||||
{
|
||||
await dialog.AcceptAsync();
|
||||
};
|
||||
await Page.GetByRole(AriaRole.Button).ClickAsync();
|
||||
```
|
||||
|
||||
:::note
|
||||
@ -116,10 +119,10 @@ page.close(run_before_unload=True)
|
||||
```
|
||||
|
||||
```csharp
|
||||
page.Dialog += (_, dialog) =>
|
||||
Page.Dialog += async (_, dialog) =>
|
||||
{
|
||||
Assert.AreEqual("beforeunload", dialog.Type);
|
||||
dialog.DismissAsync();
|
||||
await dialog.DismissAsync();
|
||||
};
|
||||
await page.CloseAsync(runBeforeUnload: true);
|
||||
await Page.CloseAsync(new() { RunBeforeUnload = true });
|
||||
```
|
||||
|
@ -550,7 +550,7 @@ await page.RouteAsync("**/*", async route => {
|
||||
});
|
||||
|
||||
// Continue requests as POST.
|
||||
await page.RouteAsync("**/*", async route => await route.ContinueAsync(method: "POST"));
|
||||
await Page.RouteAsync("**/*", async route => await route.ContinueAsync(new() { Method = "POST" }));
|
||||
```
|
||||
|
||||
You can continue requests with modifications. Example above removes an HTTP header from the outgoing requests.
|
||||
|
Loading…
Reference in New Issue
Block a user