Skip to content

Commit

Permalink
docs(consoleMessage): add missing console message comments (#6320)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Schmitt <max@schmitt.mx>
  • Loading branch information
kblok and mxschmitt committed May 5, 2021
1 parent 90de864 commit 9e36f5c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/src/api/class-consolemessage.md
Expand Up @@ -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]>
Expand All @@ -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]>

Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/class-page.md
Expand Up @@ -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());
});
Expand Down
4 changes: 2 additions & 2 deletions docs/src/verification.md
Expand Up @@ -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());
});
Expand Down
7 changes: 7 additions & 0 deletions types/types.d.ts
Expand Up @@ -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(): {
Expand All @@ -9055,6 +9059,9 @@ export interface ConsoleMessage {
columnNumber: number;
};

/**
* The text of the console message.
*/
text(): string;

/**
Expand Down

0 comments on commit 9e36f5c

Please sign in to comment.