[Bug]: tracing.stop(path=...) and record_har_path ignore os.chdir() for relative paths
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
The reporter points at Artifact.save_as, which already absolutizes its path before sending it to the driver; start there and see how it does it. Then find the two places that serialize tracing.stop(path=...) and the record_har_path context option to the driver and give them the same treatment. The repro script in the issue is the check: after os.chdir(target), trace.zip and rel.har should land in the new cwd just like shot.png does, in both the sync and async APIs.
Written by the indexing model from the issue text.
Description
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:
- Dominant language
- Python
- Stars
- 15.1k
- Forks
- 1.3k
- Avg merge
- 6h 16m
- Merged PRs (30d)
- 53
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/playwright-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/playwright-python#3360 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
microsoft/playwright-python#3362 ·
Maintainers usually reply within 1 day
All issues in microsoft/playwright-python
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
snap-stanford/Biomni#380 ·
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainers usually reply within 1 day
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cubrid-lab/pycubrid#1307 ·
Maintainers usually reply within 1 day
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainers usually reply within 1 day
-
bug high-severity
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainers usually reply within 1 day