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

未关闭 适合新手
#5,153 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
playwright, python
领域
testing-qa

调研方向

从 Browser/keywords/playwright_state.py 第 911 行附近开始,跟踪 close_context() 直到其 trace flush。将这条路径与 Browser/browser.py:838-848 中的 cleanup 进行比较,后者只会从 _start_suite listener hook 运行。复现仅使用 Python 的示例,并确认关闭一个启用了 tracing 的 context 不会在 browser/traces/temp// 下留下目录。

由索引模型根据 Issue 内容生成。

描述

Tracing writes its working files to browser/traces/temp/<uuid>/ (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
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/<uuid>/
    <name>.trace
    <name>.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.

主要语言
Python
星标
662
派生
149
平均合并
6 小时 13 分钟
30 天内合并 PR
121

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MarketSquare/robotframework-browser 的其他 Issue

查看 MarketSquare/robotframework-browser 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。