mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00: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
|
```csharp
|
||||||
context.Dialog += (_, dialog) => dialog.AcceptAsync();
|
Context.Dialog += async (_, dialog) =>
|
||||||
|
{
|
||||||
|
await dialog.AcceptAsync();
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
@ -390,7 +393,7 @@ browser_context.add_init_script(path="preload.js")
|
|||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
await context.AddInitScriptAsync(scriptPath: "preload.js");
|
await Context.AddInitScriptAsync(scriptPath: "preload.js");
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
@ -1180,7 +1183,7 @@ context.route("/api/**", handle_route)
|
|||||||
await page.RouteAsync("/api/**", async r =>
|
await page.RouteAsync("/api/**", async r =>
|
||||||
{
|
{
|
||||||
if (r.Request.PostData.Contains("my-string"))
|
if (r.Request.PostData.Contains("my-string"))
|
||||||
await r.FulfillAsync(body: "mocked-data");
|
await r.FulfillAsync(new() { Body = "mocked-data" });
|
||||||
else
|
else
|
||||||
await r.ContinueAsync();
|
await r.ContinueAsync();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -608,7 +608,7 @@ page.add_init_script(path="./preload.js")
|
|||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
await page.AddInitScriptAsync(scriptPath: "./preload.js");
|
await Page.AddInitScriptAsync(scriptPath: "./preload.js");
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|||||||
@ -32,8 +32,11 @@ page.get_by_role("button").click()
|
|||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
page.Dialog += (_, dialog) => dialog.AcceptAsync();
|
Page.Dialog += async (_, dialog) =>
|
||||||
await page.GetByRole(AriaRole.Button).ClickAsync();
|
{
|
||||||
|
await dialog.AcceptAsync();
|
||||||
|
};
|
||||||
|
await Page.GetByRole(AriaRole.Button).ClickAsync();
|
||||||
```
|
```
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
@ -116,10 +119,10 @@ page.close(run_before_unload=True)
|
|||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
page.Dialog += (_, dialog) =>
|
Page.Dialog += async (_, dialog) =>
|
||||||
{
|
{
|
||||||
Assert.AreEqual("beforeunload", dialog.Type);
|
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.
|
// 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.
|
You can continue requests with modifications. Example above removes an HTTP header from the outgoing requests.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user