mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
docs: fix java console message snippet (#20171)
Fixes https://github.com/microsoft/playwright-java/issues/1168
This commit is contained in:
parent
0656ab4811
commit
c36827433d
@ -28,16 +28,16 @@ await msg.args[1].jsonValue() // 42
|
||||
```
|
||||
|
||||
```java
|
||||
// Listen for all System.out.printlns
|
||||
// Listen for all console messages and print them to the standard output.
|
||||
page.onConsoleMessage(msg -> System.out.println(msg.text()));
|
||||
|
||||
// Listen for all console events and handle errors
|
||||
// Listen for all console messages and print errors to the standard output.
|
||||
page.onConsoleMessage(msg -> {
|
||||
if ("error".equals(msg.type()))
|
||||
System.out.println("Error text: " + msg.text());
|
||||
});
|
||||
|
||||
// Get the next System.out.println
|
||||
// Get the next console message
|
||||
ConsoleMessage msg = page.waitForConsoleMessage(() -> {
|
||||
// Issue console.log inside the page
|
||||
page.evaluate("console.log('hello', 42, { foo: 'bar' });");
|
||||
|
Loading…
Reference in New Issue
Block a user