api(dotnet): remove whenall (#6768)

This commit is contained in:
Pavel Feldman 2021-05-26 15:50:42 -07:00 committed by GitHub
parent 9f3e66566b
commit fb3c6e50d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 42 deletions

View file

@ -1425,10 +1425,12 @@ with frame.expect_navigation():
``` ```
```csharp ```csharp
await Task.WhenAll( await frame.RunAndWaitForNavigationAsync(async () =>
frame.WaitForNavigationAsync(), {
// clicking the link will indirectly cause a navigation // Clicking the link will indirectly cause a navigation.
frame.ClickAsync("a.delayed-navigation")); await frame.ClickAsync("a.delayed-navigation"));
});
// Resolves after navigation has finished // Resolves after navigation has finished
``` ```

View file

@ -3273,8 +3273,12 @@ with page.expect_navigation():
``` ```
```csharp ```csharp
await Task.WhenAll(page.WaitForNavigationAsync(), await page.RunAndWaitForNavigationAsync(async () =>
frame.ClickAsync("a.delayed-navigation")); // clicking the link will indirectly cause a navigation {
// Clicking the link will indirectly cause a navigation.
await page.ClickAsync("a.delayed-navigation"));
});
// The method continues after navigation has finished // The method continues after navigation has finished
``` ```
@ -3336,7 +3340,7 @@ const [request] = await Promise.all([
``` ```
```java ```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", () -> { Request request = page.waitForRequest("https://example.com/resource", () -> {
// Triggers the request // Triggers the request
page.click("button.triggers-request"); page.click("button.triggers-request");
@ -3372,17 +3376,17 @@ second_request = second.value
``` ```
```csharp ```csharp
// Waits for the next response with the specified url // Waits for the next request with the specified url.
await Task.WhenAll(page.WaitForRequestAsync("https://example.com/resource"), await page.RunAndWaitForRequestAsync(async () =>
page.ClickAsync("button.triggers-request")); {
await page.ClickAsync("button");
}, "http://example.com/resource");
// Waits for the next request matching some conditions // Alternative way with a predicate.
await Task.WhenAll(page.WaitForRequestAsync(r => "https://example.com".Equals(r.Url) && "GET" == r.Method), await page.RunAndWaitForRequestAsync(async () =>
page.ClickAsync("button.triggers-request")); {
``` await page.ClickAsync("button");
}, request => request.Url == "https://example.com" && request.Method == "GET");
```js
await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
``` ```
### param: Page.waitForRequest.action = %%-csharp-wait-for-event-action-%% ### param: Page.waitForRequest.action = %%-csharp-wait-for-event-action-%%
@ -3491,13 +3495,17 @@ return response.ok
``` ```
```csharp ```csharp
// Waits for the next response with the specified url // Waits for the next response with the specified url.
await Task.WhenAll(page.WaitForResponseAsync("https://example.com/resource"), await page.RunAndWaitForResponseAsync(async () =>
page.ClickAsync("button.triggers-response")); {
await page.ClickAsync("button.triggers-response");
}, "http://example.com/resource");
// Waits for the next response matching some conditions // Alternative way with a predicate.
await Task.WhenAll(page.WaitForResponseAsync(r => "https://example.com".Equals(r.Url) && r.Status == 200), await page.RunAndWaitForResponseAsync(async () =>
page.ClickAsync("button.triggers-response")); {
await page.ClickAsync("button");
}, response => response.Url == "https://example.com" && response.Status == 200);
``` ```
### param: Page.waitForResponse.action = %%-csharp-wait-for-event-action-%% ### param: Page.waitForResponse.action = %%-csharp-wait-for-event-action-%%

View file

@ -96,7 +96,6 @@ Receives the [WebSocketFrame] object and resolves to truthy value when the waiti
## async method: WebSocket.waitForEvent2 ## async method: WebSocket.waitForEvent2
* langs: python * langs: python
- alias-python: wait_for_event - alias-python: wait_for_event
- alias-csharp: WaitForEventAsync
- returns: <[any]> - returns: <[any]>
:::note :::note

View file

@ -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)`. 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 ## wait-for-load-state-state
- `state` <[LoadState]<"load"|"domcontentloaded"|"networkidle">> - `state` <[LoadState]<"load"|"domcontentloaded"|"networkidle">>

View file

@ -344,10 +344,11 @@ with page.expect_navigation():
```csharp ```csharp
// Using waitForNavigation with a callback prevents a race condition // Using waitForNavigation with a callback prevents a race condition
// between clicking and waiting for a navigation. // between clicking and waiting for a navigation.
await Task.WhenAll( await page.RunAndWaitForNavigationAsync(async () =>
page.WaitForNavigationAsync(), // Waits for the next navigation {
page.ClickAsync("div.delayed-navigation"); // Triggers a navigation after a timeout // Triggers a navigation after a timeout
); await page.ClickAsync("div.delayed-navigation");
});
``` ```
### Multiple navigations ### Multiple navigations
@ -393,10 +394,14 @@ with page.expect_navigation(url="**/login"):
```csharp ```csharp
// Running action in the callback of waitForNavigation prevents a race // Running action in the callback of waitForNavigation prevents a race
// condition between clicking and waiting for a navigation. // condition between clicking and waiting for a navigation.
await Task.WhenAll( await page.RunAndWaitForNavigationAsync(async () =>
page.WaitForNavigationAsync(new PageWaitForNavigationOptions { UrlString = "**/login" }), // Waits for the next navigation {
page.ClickAsync("a") // Triggers a navigation with a script redirect // Triggers a navigation with a script redirect.
); await page.ClickAsync("a");
}, new PageWaitForNavigationOptions
{
UrlString = "**/login"
});
``` ```
### Loading a popup ### Loading a popup

4
types/types.d.ts vendored
View file

@ -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 urlOrPredicate Request URL string, regex or predicate receiving [Request] object.
* @param options * @param options
*/ */