[Bug]: tracing.stop(path=...) and record_har_path ignore os.chdir() for relative paths
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
报告者指出 Artifact.save_as,它在发送给 driver 之前已经将路径转为绝对路径;从那里开始,看看它是怎么做的。然后找到将 tracing.stop(path=...) 和 record_har_path 上下文选项序列化给 driver 的两个地方,并对它们做同样的处理。issue 里的复现脚本就是检查:在执行 os.chdir(target) 之后,trace.zip 和 rel.har 应该像 shot.png 一样落到新的 cwd 中,在 sync 和 async 两种 API 中都是如此。
由索引模型根据 Issue 内容生成。
描述
Version
1.65.2 (same on 1.64.0)
Steps to reproduce
Relative paths for traces and HARs are resolved against the directory the driver was started in, not the current one. Screenshots use the current one, so in one script the files end up in two places:
import os, tempfile
from playwright.sync_api import sync_playwright
start = os.getcwd()
with sync_playwright() as p:
target = tempfile.mkdtemp()
os.chdir(target)
ctx = p.chromium.launch().new_context(record_har_path="rel.har")
ctx.tracing.start()
page = ctx.new_page()
page.goto("data:text/html,x")
ctx.tracing.stop(path="trace.zip")
page.screenshot(path="shot.png")
ctx.close()
for f in ("trace.zip", "rel.har", "shot.png"):
print(f, os.path.exists(os.path.join(target, f)), os.path.exists(os.path.join(start, f)))
Expected behavior
All three files in target.
Actual behavior
trace.zip False True
rel.har False True
shot.png True False
Hits anyone using monkeypatch.chdir() with a session-scoped playwright. Artifact.save_as already makes the path absolute before sending it; tracing and HAR don't.
Additional context
No response
Environment
- Operating System: macOS 27.2
- CPU: arm64
- Browser: Chromium
- Python Version: 3.14
- Other info:
- 主要语言
- Python
- 星标
- 15.1k
- 派生
- 1.3k
- 平均合并
- 6 小时 16 分钟
- 30 天内合并 PR
- 53
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/playwright-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
microsoft/playwright-python#3360 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 62/100
microsoft/playwright-python#3362 ·
维护者通常 1 天内回复
查看 microsoft/playwright-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
snap-stanford/Biomni#380 ·
-
documentation priority: low size: S status: needs triage
难度 2/5 1-3 小时 新手友好度 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
维护者通常 1 天内回复
-
documentation priority: low size: S status: needs triage
难度 2/5 1-3 小时 新手友好度 72/100
cubrid-lab/pycubrid#1307 ·
维护者通常 1 天内回复
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't work未关闭bug
难度 2/5 1-3 小时 新手友好度 80/100
ShaftHQ/chaosengine-harness#143 ·
维护者通常 1 天内回复
-
bug high-severity
难度 2/5 1-3 小时 新手友好度 72/100
aws/bedrock-agentcore-sdk-python#752 ·
维护者通常 1 天内回复