Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(dotnet): route examples (#6578)

Anže Vodovnikec0b4e90614a
diff --git a/docs/src/api/class-route.md b/docs/src/api/class-route.md
index 0b33a5f930..19db4c58ec 100644
--- a/docs/src/api/class-route.md
+++ b/docs/src/api/class-route.md
@@ -84,6 +84,15 @@ def handle(route, request):
page.route("**/*", handle)
```
+```csharp
+await page.RouteAsync("**/*", route =>
+{
+ var headers = new Dictionary<string, string>(route.Request.Headers) { { "foo", "bar" } };
+ headers.Remove("origin");
+ route.ResumeAsync(headers);
+});
+```
+
### option: Route.continue.url
- `url` <[string]>
@@ -143,6 +152,13 @@ page.route("**/*", lambda route: route.fulfill(
body="not found!"))
```
+```csharp
+await page.RouteAsync("**/*", route => route.FulfillAsync(
+ status: 404,
+ contentType: "text/plain",
+ body: "Not Found!"));
+```
+
An example of serving static file:
```js
@@ -162,6 +178,10 @@ await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.
page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
```
+```csharp
+await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(path: "mock_data.json"));
+```
+
### option: Route.fulfill.status
- `status` <[int]>