[Bug]: tracing.stop(path=...) and record_har_path ignore os.chdir() for relative paths
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
報告者は Artifact.save_as を指摘しており、これはドライバーに送る前にすでにパスを絶対化しています。そこから始めて、それがどのように行っているかを確認してください。次に、tracing.stop(path=...) と record_har_path コンテキストオプションをドライバーにシリアライズしている 2 か所を見つけ、同じ扱いをしてください。issue 内の再現スクリプトがチェックです。os.chdir(target) の後、trace.zip と rel.har は、sync と async の両方の API で、shot.png と同様に新しい cwd に置かれるはずです。
索引モデルが 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分
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信