MarketSquare / MarketSquare/robotframework-browser

Tracing temp directories are never cleaned up when keywords are called from Python outside a Robot Framework run

Open Beginner friendly
#5,153 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Tracing writes its working files to `browser/traces/temp//` (`Browser/keywords/playwright_state.py:911`). Those are cleaned up from the `_start_suite` listener hook (`Browser/browser.py:838-848`), which only fires during a Robot Framework run. When keywords are called directly from Python the hook never runs, so the temp directories accumulate and are never removed.

### Reproduce

```python
from Browser import Browser

browser = Browser()
browser.new_browser("webkit", headless=True)
browser.new_context(tracing=True)
browser.new_page("https://robotframework-browser.org")
browser.close_context()
browser.close_browser("ALL")
```

Observed afterwards, left in place:

```
browser/traces/temp//
.trace
.network
resources/*.jpeg
```

The trace zip itself is produced correctly by `close_context()`; it is only the temp working directory that is left behind, once per traced context.

Note that with the default `outputdir` these land inside the installed package rather than the caller's working directory — that part is a separate issue about the relative default `outputdir`, and it is filed on its own. This report is about the cleanup never happening at all, which remains true even when `outputdir` is absolute.

### Suggested fix

Remove the temp directory when the trace is flushed in `close_context()`, rather than relying on a listener hook that only exists during a Robot Framework run.

### Environment

Browser 20.3.0, Robot Framework 7.4.1, Python 3.14.7, macOS, webkit.

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 in Browser/keywords/playwright_state.py around line 911 and follow close_context() through its trace flush. Compare that path with the cleanup in Browser/browser.py:838-848, which only runs from the _start_suite listener hook. Reproduce the Python-only example and confirm that closing a traced context leaves no directory under browser/traces/temp//.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.