Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(consoleMessage): add missing console message comments (#6320)

Darío Kondratiuk9e36f5cc26d0
diff --git a/docs/src/api/class-consolemessage.md b/docs/src/api/class-consolemessage.md
index 463d39b516..78667c7c51 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 75d9f86cd7..a4279dffde 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 8a997c71ea..d3aadcc613 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 540c2e7928..446de0dbb2 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<JSHandle>;
location(): {
@@ -9055,6 +9059,9 @@ export interface ConsoleMessage {
columnNumber: number;
};
+ /**
+ * The text of the console message.
+ */
text(): string;
/**