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

Function test_expose_binding

tests/async/test_page.py:438–452  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

436
437
438async def test_expose_binding(page: Page) -> None:
439 binding_source = []
440
441 def binding(source: Dict, a: int, b: int) -> int:
442 binding_source.append(source)
443 return a + b
444
445 await page.expose_binding("add", lambda source, a, b: binding(source, a, b))
446
447 result = await page.evaluate("add(5, 6)")
448
449 assert binding_source[0]["context"] == page.context
450 assert binding_source[0]["page"] == page
451 assert binding_source[0]["frame"] == page.main_frame
452 assert result == 11
453
454
455async def test_expose_function(page: Page, server: Server) -> None:

Callers

nothing calls this directly

Calls 3

bindingFunction · 0.70
expose_bindingMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected