diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index d2eaccc93b..742eafbbfa 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -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. \ No newline at end of file +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-%% diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 76d7793839..1670e1dc98 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -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 @@ -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]> @@ -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 @@ -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]>> diff --git a/docs/src/api/class-websocket.md b/docs/src/api/class-websocket.md index 980ac81fe5..c3f184a1b7 100644 --- a/docs/src/api/class-websocket.md +++ b/docs/src/api/class-websocket.md @@ -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-%% diff --git a/docs/src/api/class-websocketframe.md b/docs/src/api/class-websocketframe.md new file mode 100644 index 0000000000..3c22dc6d78 --- /dev/null +++ b/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. diff --git a/docs/src/api/class-worker.md b/docs/src/api/class-worker.md index e8dd0b0ffe..4c2997aa14 100644 --- a/docs/src/api/class-worker.md +++ b/docs/src/api/class-worker.md @@ -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-%% diff --git a/docs/src/api/java.md b/docs/src/api/java.md index 06337cea1e..97507c0093 100644 --- a/docs/src/api/java.md +++ b/docs/src/api/java.md @@ -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-%% diff --git a/docs/src/api/params.md b/docs/src/api/params.md index f276e01a62..daa9a855cb 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -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]>> @@ -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. diff --git a/docs/src/api/python.md b/docs/src/api/python.md index 755596292d..ad2d893492 100644 --- a/docs/src/api/python.md +++ b/docs/src/api/python.md @@ -85,121 +85,44 @@ Raw script content. * langs: python - returns: <[EventContextManager]> ### 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 * langs: python - returns: <[EventContextManager]> ### 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 * langs: python - returns: <[EventContextManager]> ### 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 - returns: <[EventContextManager]<[Download]>> -Performs action and waits for `download` event to fire. If predicate is provided, it passes -[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 +## async method: Page.waitForPopup * langs: python - returns: <[EventContextManager]<[Page]>> -Performs action and waits for `popup` event to fire. If predicate is provided, it passes -[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 +## async method: Page.waitForWorker * langs: python - returns: <[EventContextManager]<[Worker]>> -Performs action and waits for `worker` event to fire. If predicate is provided, it passes -[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 +## async method: Page.waitForConsoleMessage * langs: python - returns: <[EventContextManager]<[ConsoleMessage]>> -Performs action and waits for `console` event to fire. If predicate is provided, it passes -[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 +## async method: Page.waitForFileChooser * langs: python - returns: <[EventContextManager]<[FileChooser]>> -Performs action and waits for `filechooser` event to fire. If predicate is provided, it passes -[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 +## async method: BrowserContext.waitForPage * langs: python - 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 * langs: python - 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-%% ### 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 * 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-%% ### 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 * 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-%% ### 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-%%