mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs(java): add waitForCondition method (#21768)
https://github.com/microsoft/playwright-java/issues/1228
This commit is contained in:
parent
f484b833ae
commit
a61b544932
@ -1324,6 +1324,38 @@ Optional handler function used to register a routing with [`method: BrowserConte
|
|||||||
|
|
||||||
Optional handler function used to register a routing with [`method: BrowserContext.route`].
|
Optional handler function used to register a routing with [`method: BrowserContext.route`].
|
||||||
|
|
||||||
|
## async method: BrowserContext.waitForCondition
|
||||||
|
* since: v1.32
|
||||||
|
* langs: java
|
||||||
|
|
||||||
|
The method will block until the condition returns true. All Playwright events will
|
||||||
|
be dispatched while the method is waiting for the condition.
|
||||||
|
|
||||||
|
**Usage**
|
||||||
|
|
||||||
|
Use the method to wait for a condition that depends on page events:
|
||||||
|
|
||||||
|
```java
|
||||||
|
List<String> failedUrls = new ArrayList<>();
|
||||||
|
context.onResponse(response -> {
|
||||||
|
if (!response.ok()) {
|
||||||
|
failedUrls.add(response.url());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
page1.getByText("Create user").click();
|
||||||
|
page2.getByText("Submit button").click();
|
||||||
|
context.waitForCondition(() -> failedUrls.size() > 3);
|
||||||
|
```
|
||||||
|
|
||||||
|
### param: BrowserContext.waitForCondition.condition
|
||||||
|
* since: v1.32
|
||||||
|
- `condition` <[BooleanSupplier]>
|
||||||
|
|
||||||
|
Condition to wait for.
|
||||||
|
|
||||||
|
### option: BrowserContext.waitForCondition.timeout = %%-wait-for-function-timeout-%%
|
||||||
|
* since: v1.32
|
||||||
|
|
||||||
## async method: BrowserContext.waitForEvent
|
## async method: BrowserContext.waitForEvent
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
* langs: js, python
|
* langs: js, python
|
||||||
|
@ -4784,6 +4784,33 @@ class FrameExamples
|
|||||||
### option: Page.waitForSelector.timeout = %%-input-timeout-js-%%
|
### option: Page.waitForSelector.timeout = %%-input-timeout-js-%%
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
|
|
||||||
|
## async method: Page.waitForCondition
|
||||||
|
* since: v1.32
|
||||||
|
* langs: java
|
||||||
|
|
||||||
|
The method will block until the codition returns true. All Playwright events will
|
||||||
|
be dispatched while the method is waiting for the codition.
|
||||||
|
|
||||||
|
**Usage**
|
||||||
|
|
||||||
|
Use the method to wait for a condition that depends on page events:
|
||||||
|
|
||||||
|
```java
|
||||||
|
List<String> messages = new ArrayList<>();
|
||||||
|
page.onConsoleMessage(m -> messages.add(m.text()));
|
||||||
|
page.getByText("Submit button").click();
|
||||||
|
page.waitForCondition(() -> messages.size() > 3);
|
||||||
|
```
|
||||||
|
|
||||||
|
### param: Page.waitForCondition.condition
|
||||||
|
* since: v1.32
|
||||||
|
- `condition` <[BooleanSupplier]>
|
||||||
|
|
||||||
|
Codition to wait for.
|
||||||
|
|
||||||
|
### option: Page.waitForCondition.timeout = %%-wait-for-function-timeout-%%
|
||||||
|
* since: v1.32
|
||||||
|
|
||||||
## async method: Page.waitForTimeout
|
## async method: Page.waitForTimeout
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user