MarketSquare / MarketSquare/robotframework-browser

Add `Start Tracing` / `Stop Tracing` / `Start Trace Chunk` / `Stop Trace Chunk` keywords for ad-hoc tracing

Open
#5,122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
655
Forks
147
Avg merge
5h 27m
Merged PRs (30d)
59

Description

Use case

Today tracing is all-or-nothing: it can only be enabled for a whole context via the tracing argument of New Context, producing one trace for everything that context ever did. Users debugging a single flaky test case, or wanting a small shareable trace of just one scenario, cannot start tracing mid-test, cannot stop it early, cannot give the trace a human-readable title for the trace viewer, and cannot include source files. The only workaround is restructuring suites so that the interesting steps run in their own dedicated context — invasive and often impossible.

Playwright's Tracing API supports exactly this: start/stop on demand, plus chunks — multiple separate trace files recorded within one tracing session, each covering only the actions between startChunk and stopChunk.

Proposed keyword / arguments

Start Tracing    *, screenshots=True    snapshots=True    sources=False    title=None    name=None    live=False
Stop Tracing    path=None
Start Trace Chunk    *, title=None    name=None
Stop Trace Chunk    path=None
  • Start Tracing (Setter) begins tracing on the current context. title names the trace in the trace viewer; sources=True embeds source files; live enables live-viewable traces; name prefixes intermediate trace files in the traces dir.
  • Stop Tracing (Getter) stops tracing, saves the zip to path (default: a generated file under the library's output directory) and returns the file path.
  • Start Trace Chunk / Stop Trace Chunk record only the actions in between into a separate trace file within the same tracing session, so one long-lived context can yield one small trace per scenario.
New Context
Start Tracing    title=Login flow    sources=True
Go To    ${LOGIN_URL}
Start Trace Chunk    title=Submit credentials
Fill Text    id=user    alice
Click    id=submit
${chunk}=    Stop Trace Chunk    path=${OUTPUT_DIR}/traces/login-submit.zip
${trace}=    Stop Tracing    path=${OUTPUT_DIR}/traces/login-full.zip

Playwright API

Implementation notes

  • protobuf/playwright.proto: RPCs for start/stop/startChunk/stopChunk with the option fields.
  • node/playwright-wrapper: calls on the current context's tracing object; must coexist with the existing New Context tracing= mechanism (guard against double-start with a clear error). Note the library already wraps every keyword in tracing.group internally — chunk boundaries slot into that unchanged.
  • Python: keywords in Browser/keywords (natural fit: playwright_state.py or a new tracing module), docs, stub regen; atest verifying a valid trace zip is produced mid-context and that chunks contain only their own actions.

Backwards compatibility

Purely additive: four new keywords. The existing New Context tracing= shortcut keeps working unchanged; starting tracing twice is an explicit error rather than a behavior change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with protobuf/playwright.proto and the calls in node/playwright-wrapper, then inspect the keyword patterns in Python's Browser/keywords. Run the atest coverage described in the issue, checking that a mid-context trace produces a valid zip and that chunks contain only their own actions. Done also requires the existing New Context tracing= behavior to remain intact and double-starting to report a clear error.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
testing, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.