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

Function test_should_collect_two_traces

tests/async/test_tracing.py:209–244  ·  view source on GitHub ↗
(
    context: BrowserContext,
    page: Page,
    server: Server,
    tmp_path: Path,
    show_trace_viewer: Callable[[Path], AsyncContextManager[TraceViewerPage]],
)

Source from the content-addressed store, hash-verified

207
208
209async def test_should_collect_two_traces(
210 context: BrowserContext,
211 page: Page,
212 server: Server,
213 tmp_path: Path,
214 show_trace_viewer: Callable[[Path], AsyncContextManager[TraceViewerPage]],
215) -> None:
216 await context.tracing.start(screenshots=True, snapshots=True)
217 await page.goto(server.EMPTY_PAGE)
218 await page.set_content("<button>Click</button>")
219 await page.click('"Click"')
220 tracing1_path = tmp_path / "trace1.zip"
221 await context.tracing.stop(path=tracing1_path)
222
223 await context.tracing.start(screenshots=True, snapshots=True)
224 await page.dblclick('"Click"')
225 await page.close()
226 tracing2_path = tmp_path / "trace2.zip"
227 await context.tracing.stop(path=tracing2_path)
228
229 async with show_trace_viewer(tracing1_path) as trace_viewer:
230 await expect(trace_viewer.action_titles).to_have_text(
231 [
232 re.compile(r'Navigate to "/empty\.html"'),
233 re.compile(r"Set content"),
234 re.compile(r"Click"),
235 ]
236 )
237
238 async with show_trace_viewer(tracing2_path) as trace_viewer:
239 await expect(trace_viewer.action_titles).to_have_text(
240 [
241 re.compile(r"Double click"),
242 re.compile(r"Close"),
243 ]
244 )
245
246
247async def test_should_work_with_playwright_context_managers(

Callers

nothing calls this directly

Calls 9

show_trace_viewerFunction · 0.70
startMethod · 0.45
gotoMethod · 0.45
set_contentMethod · 0.45
clickMethod · 0.45
stopMethod · 0.45
dblclickMethod · 0.45
closeMethod · 0.45
to_have_textMethod · 0.45

Tested by

no test coverage detected