MCPcopy Create free account
hub / github.com/microsoft/playwright-python / test_should_collect_two_traces

Function test_should_collect_two_traces

tests/sync/test_tracing.py:212–247  ·  view source on GitHub ↗
(
    context: BrowserContext,
    page: Page,
    server: Server,
    tmp_path: Path,
    show_trace_viewer: Callable[[Path], ContextManager[TraceViewerPage]],
)

Source from the content-addressed store, hash-verified

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