MCPcopy Index your code
hub / github.com/microsoft/playwright-python / test_console_should_work

Function test_console_should_work

tests/async/test_console.py:23–38  ·  view source on GitHub ↗
(page: Page, browser_name: str)

Source from the content-addressed store, hash-verified

21
22
23async def test_console_should_work(page: Page, browser_name: str) -> None:
24 messages: List[ConsoleMessage] = []
25 page.once("console", lambda m: messages.append(m))
26 async with page.expect_console_message() as message_info:
27 await page.evaluate('() => console.log("hello", 5, {foo: "bar"})')
28 message = await message_info.value
29 if browser_name != "firefox":
30 assert message.text == "hello 5 {foo: bar}"
31 assert str(message) == "hello 5 {foo: bar}"
32 else:
33 assert message.text == "hello 5 JSHandle@object"
34 assert str(message) == "hello 5 JSHandle@object"
35 assert message.type == "log"
36 assert await message.args[0].json_value() == "hello"
37 assert await message.args[1].json_value() == 5
38 assert await message.args[2].json_value() == {"foo": "bar"}
39
40
41async def test_console_should_emit_same_log_twice(page: Page) -> None:

Callers

nothing calls this directly

Calls 5

appendMethod · 0.80
onceMethod · 0.45
evaluateMethod · 0.45
json_valueMethod · 0.45

Tested by

no test coverage detected