docs: define java specific waitFor* methods (#5315)

This commit is contained in:
Yury Semikhatsky 2021-02-04 21:15:14 -08:00 committed by GitHub
parent 0cbb2c14e6
commit 28e5975772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 219 additions and 92 deletions

View file

@ -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 - `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`]. 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-%%

View file

@ -2173,6 +2173,46 @@ Video object associated with this page.
- `width` <[int]> page width in pixels. - `width` <[int]> page width in pixels.
- `height` <[int]> page height 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 ## async method: Page.waitForEvent
* langs: csharp, js, python * langs: csharp, js, python
- alias-python: expect_event - alias-python: expect_event
@ -2211,6 +2251,22 @@ frame = event_info.value
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: 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 ## async method: Page.waitForFunction
- returns: <[JSHandle]> - returns: <[JSHandle]>
@ -2399,6 +2455,22 @@ Shortcut for main frame's [`method: Frame.waitForNavigation`].
### option: Page.waitForNavigation.waitUntil = %%-navigation-wait-until-%% ### 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 ## async method: Page.waitForRequest
* langs: * langs:
* alias-python: expect_request * alias-python: expect_request
@ -2583,6 +2655,37 @@ Shortcut for main frame's [`method: Frame.waitForTimeout`].
A timeout to wait for 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 ## method: Page.workers
- returns: <[Array]<[Worker]>> - returns: <[Array]<[Worker]>>

View file

@ -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`]. - `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.
## 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-%%

View file

@ -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.

View file

@ -71,3 +71,11 @@ Optional argument to pass to [`param: expression`].
## method: Worker.url ## method: Worker.url
- returns: <[string]> - 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-%%

View file

@ -3,6 +3,32 @@
Terminates this instance of Playwright, will also close all created browsers if they are still running. 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.launch.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
### option: BrowserType.launchPersistentContext.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%% ### option: BrowserType.launchPersistentContext.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
### option: BrowserType.launch.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%% ### option: BrowserType.launch.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%

View file

@ -440,6 +440,12 @@ method resolves immediately. Can be one of:
* `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired. * `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
* `'networkidle'` - wait until there are no network connections for at least `500` ms. * `'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 ## python-select-options-element
* langs: python * langs: python
- `element` <[ElementHandle]|[Array]<[ElementHandle]>> - `element` <[ElementHandle]|[Array]<[ElementHandle]>>
@ -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. Receives the event data and resolves to truthy value when the waiting should resolve.
## python-wait-for-event-timeout ## wait-for-event-timeout
* langs: python * langs: csharp, java, python
- `timeout` <[float]> - `timeout` <[float]>
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.

View file

@ -85,121 +85,44 @@ Raw script content.
* langs: python * langs: python
- returns: <[EventContextManager]> - returns: <[EventContextManager]>
### option: Page.waitForEvent.predicate = %%-python-wait-for-event-predicate-%% ### option: Page.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
### option: Page.waitForEvent.timeout = %%-python-wait-for-event-timeout-%% ### option: Page.waitForEvent.timeout = %%-wait-for-event-timeout-%%
## async method: BrowserContext.waitForEvent ## async method: BrowserContext.waitForEvent
* langs: python * langs: python
- returns: <[EventContextManager]> - returns: <[EventContextManager]>
### option: BrowserContext.waitForEvent.predicate = %%-python-wait-for-event-predicate-%% ### option: BrowserContext.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
### option: BrowserContext.waitForEvent.timeout = %%-python-wait-for-event-timeout-%% ### option: BrowserContext.waitForEvent.timeout = %%-wait-for-event-timeout-%%
## async method: WebSocket.waitForEvent ## async method: WebSocket.waitForEvent
* langs: python * langs: python
- returns: <[EventContextManager]> - returns: <[EventContextManager]>
### option: WebSocket.waitForEvent.predicate = %%-python-wait-for-event-predicate-%% ### option: WebSocket.waitForEvent.predicate = %%-python-wait-for-event-predicate-%%
### option: WebSocket.waitForEvent.timeout = %%-python-wait-for-event-timeout-%% ### option: WebSocket.waitForEvent.timeout = %%-wait-for-event-timeout-%%
## async method: Page.expectDownload ## async method: Page.waitForDownload
* langs: python * langs: python
- returns: <[EventContextManager]<[Download]>> - returns: <[EventContextManager]<[Download]>>
Performs action and waits for `download` event to fire. If predicate is provided, it passes ## async method: Page.waitForPopup
[Download] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the page is closed before the download event is fired.
### option: Page.expectDownload.predicate =
* langs: python
- `predicate` <[function]\([Download]\):[bool]>
Receives the [Download] object and resolves to truthy value when the waiting should resolve.
### option: Page.expectDownload.timeout = %%-python-wait-for-event-timeout-%%
## async method: Page.expectPopup
* langs: python * langs: python
- returns: <[EventContextManager]<[Page]>> - returns: <[EventContextManager]<[Page]>>
Performs action and waits for `popup` event to fire. If predicate is provided, it passes ## async method: Page.waitForWorker
[Popup] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the page is closed before the popup event is fired.
### option: Page.expectPopup.predicate =
* langs: python
- `predicate` <[function]\([Page]\):[bool]>
Receives the [Popup] object and resolves to truthy value when the waiting should resolve.
### option: Page.expectPopup.timeout = %%-python-wait-for-event-timeout-%%
## async method: Page.expectWorker
* langs: python * langs: python
- returns: <[EventContextManager]<[Worker]>> - returns: <[EventContextManager]<[Worker]>>
Performs action and waits for `worker` event to fire. If predicate is provided, it passes ## async method: Page.waitForConsoleMessage
[Worker] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the page is closed before the worker event is fired.
### option: Page.expectWorker.predicate =
* langs: python
- `predicate` <[function]\([Worker]\):[bool]>
Receives the [Worker] object and resolves to truthy value when the waiting should resolve.
### option: Page.expectWorker.timeout = %%-python-wait-for-event-timeout-%%
## async method: Page.expectConsoleMessage
* langs: python * langs: python
- returns: <[EventContextManager]<[ConsoleMessage]>> - returns: <[EventContextManager]<[ConsoleMessage]>>
Performs action and waits for `console` event to fire. If predicate is provided, it passes ## async method: Page.waitForFileChooser
[ConsoleMessage] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the page is closed before the worker event is fired.
### option: Page.expectConsoleMessage.predicate =
* langs: python
- `predicate` <[function]\([ConsoleMessage]\):[bool]>
Receives the [ConsoleMessage] object and resolves to truthy value when the waiting should resolve.
### option: Page.expectConsoleMessage.timeout = %%-python-wait-for-event-timeout-%%
## async method: Page.expectFileChooser
* langs: python * langs: python
- returns: <[EventContextManager]<[FileChooser]>> - returns: <[EventContextManager]<[FileChooser]>>
Performs action and waits for `filechooser` event to fire. If predicate is provided, it passes ## async method: BrowserContext.waitForPage
[FileChooser] value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
Will throw an error if the page is closed before the worker event is fired.
### option: Page.expectFileChooser.predicate =
* langs: python
- `predicate` <[function]\([FileChooser]\):[bool]>
Receives the [FileChooser] object and resolves to truthy value when the waiting should resolve.
### option: Page.expectFileChooser.timeout = %%-python-wait-for-event-timeout-%%
## async method: BrowserContext.expectPage
* langs: python * langs: python
- returns: <[EventContextManager]<[Page]>> - returns: <[EventContextManager]<[Page]>>
Performs action and waits for `page` event to fire. 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 page is closed before the worker event is fired.
### option: BrowserContext.expectPage.predicate =
* langs: python
- `predicate` <[function]\([Page]\):[bool]>
Receives the [Page] object and resolves to truthy value when the waiting should resolve.
### option: BrowserContext.expectPage.timeout = %%-python-wait-for-event-timeout-%%
## async method: Frame.waitForNavigation ## async method: Frame.waitForNavigation
* langs: python * langs: python
- returns: <[EventContextManager]<[Response]>> - returns: <[EventContextManager]<[Response]>>
@ -231,7 +154,7 @@ Will throw an error if the socket is closed before the `event` is fired.
### param: BrowserContext.waitForEvent2.event = %%-wait-for-event-event-%% ### param: BrowserContext.waitForEvent2.event = %%-wait-for-event-event-%%
### option: BrowserContext.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%% ### option: BrowserContext.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
### option: BrowserContext.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%% ### option: BrowserContext.waitForEvent2.timeout = %%-wait-for-event-timeout-%%
## async method: Page.waitForEvent2 ## async method: Page.waitForEvent2
* langs: python * langs: python
@ -248,7 +171,7 @@ Will throw an error if the socket is closed before the `event` is fired.
### param: Page.waitForEvent2.event = %%-wait-for-event-event-%% ### param: Page.waitForEvent2.event = %%-wait-for-event-event-%%
### option: Page.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%% ### option: Page.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
### option: Page.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%% ### option: Page.waitForEvent2.timeout = %%-wait-for-event-timeout-%%
## async method: WebSocket.waitForEvent2 ## async method: WebSocket.waitForEvent2
* langs: python * langs: python
@ -265,4 +188,4 @@ Will throw an error if the socket is closed before the `event` is fired.
### param: WebSocket.waitForEvent2.event = %%-wait-for-event-event-%% ### param: WebSocket.waitForEvent2.event = %%-wait-for-event-event-%%
### option: WebSocket.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%% ### option: WebSocket.waitForEvent2.predicate = %%-python-wait-for-event-predicate-%%
### option: WebSocket.waitForEvent2.timeout = %%-python-wait-for-event-timeout-%% ### option: WebSocket.waitForEvent2.timeout = %%-wait-for-event-timeout-%%