Skip to content

Commit

Permalink
docs: define java specific waitFor* methods (#5315)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Feb 5, 2021
1 parent 0cbb2c1 commit 28e5975
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 92 deletions.
19 changes: 18 additions & 1 deletion docs/src/api/class-browsercontext.md
Expand Up @@ -778,4 +778,21 @@ Event name, same one would pass into `browserContext.on(event)`.
- `timeout` <[float]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to
disable timeout. The default value can be changed by using the [`method: BrowserContext.setDefaultTimeout`].

Either a predicate that receives an event or an options object. Optional.
Either a predicate that receives an event or an options object. Optional.

## async method: BrowserContext.waitForPage
* langs: csharp, java, python
- alias-python: expect_page
- returns: <[Page]>

Performs action and waits for a new [Page] to be created in the context. If predicate is provided, it passes
[Page] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the context closes before new [Page] is created.

### option: BrowserContext.waitForPage.predicate =
* langs: csharp, java, python
- `predicate` <[function]\([Page]\):[bool]>

Receives the [Page] object and resolves to truthy value when the waiting should resolve.

### option: BrowserContext.waitForPage.timeout = %%-wait-for-event-timeout-%%
103 changes: 103 additions & 0 deletions docs/src/api/class-page.md
Expand Up @@ -2173,6 +2173,46 @@ Video object associated with this page.
- `width` <[int]> page width in pixels.
- `height` <[int]> page height in pixels.

## method: Page.waitForClose
* langs: csharp, java
- returns: <[Page]>

Performs action and waits for the Page to close.

### option: Page.waitForClose.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForConsoleMessage
* langs: csharp, java, python
- alias-python: expect_console_message
- returns: <[ConsoleMessage]>

Performs action and waits for a [ConoleMessage] to be logged by in the page. If predicate is provided, it passes
[ConsoleMessage] value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
Will throw an error if the page is closed before the console event is fired.

### option: Page.waitForConsoleMessage.predicate =
- `predicate` <[function]\([ConsoleMessage]\):[bool]>

Receives the [ConsoleMessage] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForConsoleMessage.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForDownload
* langs: csharp, java, python
- alias-python: expect_download
- returns: <[Download]>

Performs action and waits for a new [Download]. If predicate is provided, it passes
[Download] value into the `predicate` function and waits for `predicate(download)` to return a truthy value.
Will throw an error if the page is closed before the download event is fired.

### option: Page.waitForDownload.predicate =
- `predicate` <[function]\([Download]\):[bool]>

Receives the [Download] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForDownload.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForEvent
* langs: csharp, js, python
- alias-python: expect_event
Expand Down Expand Up @@ -2211,6 +2251,22 @@ frame = event_info.value

Either a predicate that receives an event or an options object. Optional.

## async method: Page.waitForFileChooser
* langs: csharp, java, python
- alias-python: expect_file_chooser
- returns: <[FileChooser]>

Performs action and waits for a new [FileChooser] to be created. If predicate is provided, it passes
[FileChooser] value into the `predicate` function and waits for `predicate(fileChooser)` to return a truthy value.
Will throw an error if the page is closed before the file chooser is opened.

### option: Page.waitForFileChooser.predicate =
- `predicate` <[function]\([FileChooser]\):[bool]>

Receives the [FileChooser] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForFileChooser.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForFunction
- returns: <[JSHandle]>

Expand Down Expand Up @@ -2399,6 +2455,22 @@ Shortcut for main frame's [`method: Frame.waitForNavigation`].

### option: Page.waitForNavigation.waitUntil = %%-navigation-wait-until-%%

## async method: Page.waitForPopup
* langs: csharp, java, python
- alias-python: expect_popup
- returns: <[Page]>

Performs action and waits for a popup [Page]. If predicate is provided, it passes
[Popup] value into the `predicate` function and waits for `predicate(page)` to return a truthy value.
Will throw an error if the page is closed before the popup event is fired.

### option: Page.waitForPopup.predicate =
- `predicate` <[function]\([Page]\):[bool]>

Receives the [Page] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForPopup.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForRequest
* langs:
* alias-python: expect_request
Expand Down Expand Up @@ -2583,6 +2655,37 @@ Shortcut for main frame's [`method: Frame.waitForTimeout`].

A timeout to wait for

## async method: Page.waitForWebSocket
* langs: csharp, java
- returns: <[WebSocket]>

Performs action and waits for a new [WebSocket]. If predicate is provided, it passes
[WebSocket] value into the `predicate` function and waits for `predicate(webSocket)` to return a truthy value.
Will throw an error if the page is closed before the WebSocket event is fired.

### option: Page.waitForWebSocket.predicate =
- `predicate` <[function]\([WebSocket]\):[bool]>

Receives the [WebSocket] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForWebSocket.timeout = %%-wait-for-event-timeout-%%

## async method: Page.waitForWorker
* langs: csharp, java, python
- alias-python: expect_worker
- returns: <[Worker]>

Performs action and waits for a new [Worker]. If predicate is provided, it passes
[Worker] value into the `predicate` function and waits for `predicate(worker)` to return a truthy value.
Will throw an error if the page is closed before the worker event is fired.

### option: Page.waitForWorker.predicate =
- `predicate` <[function]\([Worker]\):[bool]>

Receives the [Worker] object and resolves to truthy value when the waiting should resolve.

### option: Page.waitForWorker.timeout = %%-wait-for-event-timeout-%%

## method: Page.workers
- returns: <[Array]<[Worker]>>

Expand Down
30 changes: 30 additions & 0 deletions docs/src/api/class-websocket.md
Expand Up @@ -54,3 +54,33 @@ Event name, same one would pass into `webSocket.on(event)`.
- `timeout` <[float]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [`method: BrowserContext.setDefaultTimeout`].

Either a predicate that receives an event or an options object. Optional.

## method: WebSocket.waitForFrameReceived
* langs: csharp, java
- returns: <[WebSocketFrame]>

Performs action and waits for a frame to be sent. If predicate is provided, it passes
[WebSocketFrame] value into the `predicate` function and waits for `predicate(webSocketFrame)` to return a truthy value.
Will throw an error if the WebSocket or Page is closed before the frame is received.

### option: WebSocket.waitForFrameReceived.predicate
- `predicate` <[function]\([WebSocketFrame]\):[bool]>

Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.

### option: WebSocket.waitForFrameReceived.timeout = %%-wait-for-event-timeout-%%

## method: WebSocket.waitForFrameSent
* langs: csharp, java
- returns: <[WebSocketFrame]>

Performs action and waits for a frame to be sent. If predicate is provided, it passes
[WebSocketFrame] value into the `predicate` function and waits for `predicate(webSocketFrame)` to return a truthy value.
Will throw an error if the WebSocket or Page is closed before the frame is sent.

### option: WebSocket.waitForFrameSent.predicate
- `predicate` <[function]\([WebSocketFrame]\):[bool]>

Receives the [WebSocketFrame] object and resolves to truthy value when the waiting should resolve.

### option: WebSocket.waitForFrameSent.timeout = %%-wait-for-event-timeout-%%
14 changes: 14 additions & 0 deletions docs/src/api/class-websocketframe.md
@@ -0,0 +1,14 @@
# class: WebSocketFrame
* langs: csharp, java

The [WebSocketFrame] class represents frames sent over [WebSocket] connections in the page. Frame payload is returned by either [`method: WebSocketFrame.text`] or [`method: WebSocketFrame.binary`] method depending on the its type.

## method: WebSocketFrame.binary
- returns: <[null]|[Buffer]>

Returns binary payload.

## method: WebSocketFrame.text
- returns: <[null]|[string]>

Returns text payload.
8 changes: 8 additions & 0 deletions docs/src/api/class-worker.md
Expand Up @@ -71,3 +71,11 @@ Optional argument to pass to [`param: expression`].

## method: Worker.url
- returns: <[string]>

## method: Worker.waitForClose
* langs: csharp, java
- returns: <[Worker]>

Performs action and waits for the Worker to close.

### option: Worker.waitForClose.timeout = %%-wait-for-event-timeout-%%
26 changes: 26 additions & 0 deletions docs/src/api/java.md
Expand Up @@ -3,6 +3,32 @@

Terminates this instance of Playwright, will also close all created browsers if they are still running.

### param: BrowserContext.waitForPage.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForClose.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForDownload.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForFileChooser.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForPopup.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForRequest.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForResponse.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForWebSocket.callback = %%-java-wait-for-event-callback-%%

### param: Page.waitForWorker.callback = %%-java-wait-for-event-callback-%%

### param: WebSocket.waitForFrameReceived.callback = %%-java-wait-for-event-callback-%%

### param: WebSocket.waitForFrameSent.callback = %%-java-wait-for-event-callback-%%

### param: Worker.waitForClose.callback = %%-java-wait-for-event-callback-%%

### option: BrowserType.launch.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
### option: BrowserType.launchPersistentContext.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
### option: BrowserType.launch.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%
Expand Down
10 changes: 8 additions & 2 deletions docs/src/api/params.md
Expand Up @@ -440,6 +440,12 @@ method resolves immediately. Can be one of:
* `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
* `'networkidle'` - wait until there are no network connections for at least `500` ms.

## java-wait-for-event-callback
* langs: java
- `callback` <[Runnable]>

Callback that performs the action triggering the event.

## python-select-options-element
* langs: python
- `element` <[ElementHandle]|[Array]<[ElementHandle]>>
Expand Down Expand Up @@ -472,8 +478,8 @@ only the first option matching one of the passed options is selected. Optional.

Receives the event data and resolves to truthy value when the waiting should resolve.

## python-wait-for-event-timeout
* langs: python
## wait-for-event-timeout
* langs: csharp, java, python
- `timeout` <[float]>

Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
Expand Down

0 comments on commit 28e5975

Please sign in to comment.