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

Function test_should_be_atomic

tests/async/test_dispatch_event.py:129–151  ·  view source on GitHub ↗
(selectors: Selectors, page: Page, utils: Utils)

Source from the content-addressed store, hash-verified

127
128
129async def test_should_be_atomic(selectors: Selectors, page: Page, utils: Utils) -> None:
130 await utils.register_selector_engine(
131 selectors,
132 "dispatch_event",
133 """{
134 create(root, target) { },
135 query(root, selector) {
136 const result = root.querySelector(selector);
137 if (result)
138 Promise.resolve().then(() => result.onclick = "");
139 return result;
140 },
141 queryAll(root, selector) {
142 const result = Array.from(root.querySelectorAll(selector));
143 for (const e of result)
144 Promise.resolve().then(() => result.onclick = "");
145 return result;
146 }
147 }""",
148 )
149 await page.set_content('<div onclick="window._clicked=true">Hello</div>')
150 await page.dispatch_event("dispatch_event=div", "click")
151 assert await page.evaluate("() => window._clicked")
152
153
154async def test_should_dispatch_drag_drop_events(page: Page, server: Server) -> None:

Callers

nothing calls this directly

Calls 4

set_contentMethod · 0.45
dispatch_eventMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected