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

Function test_should_work

tests/async/test_cdp_session.py:23–35  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

21
22@pytest.mark.only_browser("chromium")
23async def test_should_work(page: Page) -> None:
24 client = await page.context.new_cdp_session(page)
25 events = []
26 client.on("Runtime.consoleAPICalled", lambda params: events.append(params))
27 await client.send("Runtime.enable")
28 result = await client.send(
29 "Runtime.evaluate",
30 {"expression": "window.foo = 'bar'; console.log('log'); 'result'"},
31 )
32 assert result == {"result": {"type": "string", "value": "result"}}
33 foo = await page.evaluate("() => window.foo")
34 assert foo == "bar"
35 assert events[0]["args"][0]["value"] == "log"
36
37
38@pytest.mark.only_browser("chromium")

Callers

nothing calls this directly

Calls 5

appendMethod · 0.80
new_cdp_sessionMethod · 0.45
onMethod · 0.45
sendMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected