(
context: BrowserContext,
page: Page,
server: Server,
tmp_path: Path,
show_trace_viewer: Callable[[Path], ContextManager[TraceViewerPage]],
)
| 210 | |
| 211 | |
| 212 | def 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 | |
| 250 | def test_should_work_with_playwright_context_managers( |
nothing calls this directly
no test coverage detected