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

Function test_should_traverse_focus

tests/async/test_focus.py:52–65  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

50
51
52async def test_should_traverse_focus(page: Page) -> None:
53 await page.set_content('<input id="i1"><input id="i2">')
54 focused = []
55 await page.expose_function("focusEvent", lambda: focused.append(True))
56 await page.evaluate("() => i2.addEventListener('focus', focusEvent)")
57
58 await page.focus("#i1")
59 await page.keyboard.type("First")
60 await page.keyboard.press("Tab")
61 await page.keyboard.type("Last")
62
63 assert focused == [True]
64 assert await page.eval_on_selector("#i1", "e => e.value") == "First"
65 assert await page.eval_on_selector("#i2", "e => e.value") == "Last"
66
67
68async def test_should_traverse_focus_in_all_directions(page: Page) -> None:

Callers

nothing calls this directly

Calls 8

appendMethod · 0.80
set_contentMethod · 0.45
expose_functionMethod · 0.45
evaluateMethod · 0.45
focusMethod · 0.45
typeMethod · 0.45
pressMethod · 0.45
eval_on_selectorMethod · 0.45

Tested by

no test coverage detected