Skip to content

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

api(dotnet): remove whenall (#6768)

Pavel Feldmanfb3c6e50d497
diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.md
index b1cc98cbad..63dfbedec3 100644
--- a/docs/src/api/class-frame.md
+++ b/docs/src/api/class-frame.md
@@ -1425,10 +1425,12 @@ with frame.expect_navigation():
```
```csharp
-await Task.WhenAll(
- frame.WaitForNavigationAsync(),
- // clicking the link will indirectly cause a navigation
- frame.ClickAsync("a.delayed-navigation"));
+await frame.RunAndWaitForNavigationAsync(async () =>
+{
+ // Clicking the link will indirectly cause a navigation.
+ await frame.ClickAsync("a.delayed-navigation"));
+});
+
// Resolves after navigation has finished
```
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index 528c6a97c1..ca64c2a63c 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -3273,8 +3273,12 @@ with page.expect_navigation():
```
```csharp
-await Task.WhenAll(page.WaitForNavigationAsync(),
- frame.ClickAsync("a.delayed-navigation")); // clicking the link will indirectly cause a navigation
+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
```
@@ -3336,7 +3340,7 @@ const [request] = await Promise.all([
```
```java
-// Waits for the next response with the specified url
+// Waits for the next request with the specified url
Request request = page.waitForRequest("https://example.com/resource", () -> {
// Triggers the request
page.click("button.triggers-request");
@@ -3372,17 +3376,17 @@ second_request = second.value
```
```csharp
-// Waits for the next response with the specified url
-await Task.WhenAll(page.WaitForRequestAsync("https://example.com/resource"),
- page.ClickAsync("button.triggers-request"));
-
-// Waits for the next request matching some conditions
-await Task.WhenAll(page.WaitForRequestAsync(r => "https://example.com".Equals(r.Url) && "GET" == r.Method),
- page.ClickAsync("button.triggers-request"));
-```
+// Waits for the next request with the specified url.
+await page.RunAndWaitForRequestAsync(async () =>
+{
+ await page.ClickAsync("button");
+}, "http://example.com/resource");
-```js
-await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
+// Alternative way with a predicate.
+await page.RunAndWaitForRequestAsync(async () =>
+{
+ await page.ClickAsync("button");
+}, request => request.Url == "https://example.com" && request.Method == "GET");
```
### param: Page.waitForRequest.action = %%-csharp-wait-for-event-action-%%
@@ -3491,13 +3495,17 @@ return response.ok
```
```csharp
-// Waits for the next response with the specified url
-await Task.WhenAll(page.WaitForResponseAsync("https://example.com/resource"),
- page.ClickAsync("button.triggers-response"));
+// Waits for the next response with the specified url.
+await page.RunAndWaitForResponseAsync(async () =>
+{
+ await page.ClickAsync("button.triggers-response");
+}, "http://example.com/resource");
-// Waits for the next response matching some conditions
-await Task.WhenAll(page.WaitForResponseAsync(r => "https://example.com".Equals(r.Url) && r.Status == 200),
- page.ClickAsync("button.triggers-response"));
+// Alternative way with a predicate.
+await page.RunAndWaitForResponseAsync(async () =>
+{
+ await page.ClickAsync("button");
+}, response => response.Url == "https://example.com" && response.Status == 200);
```
### param: Page.waitForResponse.action = %%-csharp-wait-for-event-action-%%
diff --git a/docs/src/api/class-websocket.md b/docs/src/api/class-websocket.md
index 0527c4a7b9..26e31799c8 100644
--- a/docs/src/api/class-websocket.md
+++ b/docs/src/api/class-websocket.md
@@ -96,7 +96,6 @@ Receives the [WebSocketFrame] object and resolves to truthy value when the waiti
## async method: WebSocket.waitForEvent2
* langs: python
- alias-python: wait_for_event
- - alias-csharp: WaitForEventAsync
- returns: <[any]>
:::note
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index 1b4d139fab..89a330094d 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -492,12 +492,6 @@ A glob pattern, regex pattern or predicate receiving [URL] to match while waitin
Event name, same one typically passed into `*.on(event)`.
-## csharp-wait-for-event-event
-* langs: csharp
-- `playwrightEvent` <[PlaywrightEvent<T>]>
-
-Event type, same one typically passed into `WaitForEventAsync`.
-
## wait-for-load-state-state
- `state` <[LoadState]<"load"|"domcontentloaded"|"networkidle">>
diff --git a/docs/src/navigations.md b/docs/src/navigations.md
index 8ac7931d84..4bcf9de6d7 100644
--- a/docs/src/navigations.md
+++ b/docs/src/navigations.md
@@ -344,10 +344,11 @@ with page.expect_navigation():
```csharp
// Using waitForNavigation with a callback prevents a race condition
// between clicking and waiting for a navigation.
-await Task.WhenAll(
- page.WaitForNavigationAsync(), // Waits for the next navigation
- page.ClickAsync("div.delayed-navigation"); // Triggers a navigation after a timeout
-);
+await page.RunAndWaitForNavigationAsync(async () =>
+{
+ // Triggers a navigation after a timeout
+ await page.ClickAsync("div.delayed-navigation");
+});
```
### Multiple navigations
@@ -393,10 +394,14 @@ with page.expect_navigation(url="**/login"):
```csharp
// Running action in the callback of waitForNavigation prevents a race
// condition between clicking and waiting for a navigation.
-await Task.WhenAll(
- page.WaitForNavigationAsync(new PageWaitForNavigationOptions { UrlString = "**/login" }), // Waits for the next navigation
- page.ClickAsync("a") // Triggers a navigation with a script redirect
-);
+await page.RunAndWaitForNavigationAsync(async () =>
+{
+ // Triggers a navigation with a script redirect.
+ await page.ClickAsync("a");
+}, new PageWaitForNavigationOptions
+{
+ UrlString = "**/login"
+});
```
### Loading a popup
diff --git a/types/types.d.ts b/types/types.d.ts
index 307f930e90..d1ebc50f08 100644
--- a/types/types.d.ts
+++ b/types/types.d.ts
@@ -3173,10 +3173,6 @@ export interface Page {
* ]);
* ```
*
- * ```js
- * await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
- * ```
- *
* @param urlOrPredicate Request URL string, regex or predicate receiving [Request] object.
* @param options
*/