|
14 | 14 |
|
15 | 15 | from pathlib import Path
|
16 | 16 |
|
| 17 | +from playwright.async_api import Browser, BrowserContext |
| 18 | +from tests.server import Server |
17 | 19 |
|
18 |
| -async def test_browser_context_output_trace(browser, server, tmp_path): |
| 20 | + |
| 21 | +async def test_browser_context_output_trace( |
| 22 | + browser: Browser, server: Server, tmp_path: Path |
| 23 | +): |
19 | 24 | context = await browser.new_context()
|
20 | 25 | await context.tracing.start(screenshots=True, snapshots=True)
|
21 | 26 | page = await context.new_page()
|
22 | 27 | await page.goto(server.PREFIX + "/grid.html")
|
23 | 28 | await context.tracing.stop(path=tmp_path / "trace.zip")
|
24 | 29 | assert Path(tmp_path / "trace.zip").exists()
|
| 30 | + |
| 31 | + |
| 32 | +async def test_browser_context_should_not_throw_when_stopping_without_start_but_not_exporting( |
| 33 | + context: BrowserContext, server: Server, tmp_path: Path |
| 34 | +): |
| 35 | + await context.tracing.stop() |
| 36 | + |
| 37 | + |
| 38 | +async def test_browser_context_output_trace_chunk( |
| 39 | + browser: Browser, server: Server, tmp_path: Path |
| 40 | +): |
| 41 | + context = await browser.new_context() |
| 42 | + await context.tracing.start(screenshots=True, snapshots=True) |
| 43 | + page = await context.new_page() |
| 44 | + await page.goto(server.PREFIX + "/grid.html") |
| 45 | + button = page.locator(".box").first |
| 46 | + |
| 47 | + await context.tracing.start_chunk(title="foo") |
| 48 | + await button.click() |
| 49 | + await context.tracing.stop_chunk(path=tmp_path / "trace1.zip") |
| 50 | + assert Path(tmp_path / "trace1.zip").exists() |
| 51 | + |
| 52 | + await context.tracing.start_chunk(title="foo") |
| 53 | + await button.click() |
| 54 | + await context.tracing.stop_chunk(path=tmp_path / "trace2.zip") |
| 55 | + assert Path(tmp_path / "trace2.zip").exists() |
0 commit comments