From 9e36f5cc26d0fe945289b50de4faa2167fbd1bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 5 May 2021 17:18:07 -0300 Subject: [PATCH] docs(consoleMessage): add missing console message comments (#6320) Co-authored-by: Max Schmitt --- docs/src/api/class-consolemessage.md | 4 ++++ docs/src/api/class-page.md | 2 +- docs/src/verification.md | 4 ++-- types/types.d.ts | 7 +++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/src/api/class-consolemessage.md b/docs/src/api/class-consolemessage.md index 463d39b5160c4..78667c7c51238 100644 --- a/docs/src/api/class-consolemessage.md +++ b/docs/src/api/class-consolemessage.md @@ -5,6 +5,8 @@ ## method: ConsoleMessage.args - returns: <[Array]<[JSHandle]>> +List of arguments passed to a `console` function call. See also [`event: Page.console`]. + ## method: ConsoleMessage.location * langs: js, python - returns: <[Object]> @@ -21,6 +23,8 @@ URL of the resource followed by 0-based line and column numbers in the resource ## method: ConsoleMessage.text - returns: <[string]> +The text of the console message. + ## method: ConsoleMessage.type - returns: <[string]> diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 75d9f86cd75c1..a4279dffde71d 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -145,7 +145,7 @@ await page.evaluate(() => console.log('hello', 5, {foo: 'bar'})); ``` ```java -page.onConsole(msg -> { +page.onConsoleMessage(msg -> { for (int i = 0; i < msg.args().size(); ++i) System.out.println(i + ": " + msg.args().get(i).jsonValue()); }); diff --git a/docs/src/verification.md b/docs/src/verification.md index 8a997c71ea540..d3aadcc613247 100644 --- a/docs/src/verification.md +++ b/docs/src/verification.md @@ -35,10 +35,10 @@ await msg.args[1].jsonValue() // 42 ```java // Listen for all System.out.printlns -page.onConsole(msg -> System.out.println(msg.text())); +page.onConsoleMessage(msg -> System.out.println(msg.text())); // Listen for all console events and handle errors -page.onConsole(msg -> { +page.onConsoleMessage(msg -> { if ("error".equals(msg.type())) System.out.println("Error text: " + msg.text()); }); diff --git a/types/types.d.ts b/types/types.d.ts index 540c2e7928a53..446de0dbb222f 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -9036,6 +9036,10 @@ export interface BrowserServer { * [page.on('console')](https://playwright.dev/docs/api/class-page#pageonconsole) event. */ export interface ConsoleMessage { + /** + * List of arguments passed to a `console` function call. See also + * [page.on('console')](https://playwright.dev/docs/api/class-page#pageonconsole). + */ args(): Array; location(): { @@ -9055,6 +9059,9 @@ export interface ConsoleMessage { columnNumber: number; }; + /** + * The text of the console message. + */ text(): string; /**