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

Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Darío Kondratiuk 2021-05-05 17:18:07 -03:00 committed by GitHub
parent 90de864216
commit 9e36f5cc26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View file

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

View file

@ -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());
});

View file

@ -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());
});

7
types/types.d.ts vendored
View file

@ -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;
/**