New Context recordHar with a relative path writes the HAR into the wrapper directory, also on the Robot Framework path
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Inspect Browser/keywords/playwright_state.py, especially _set_context_options and the recordVideo handling around lines 948-960, then compare the recordHar paths at lines 607, 649, and 752. Check Browser/playwright.py lines 280 and 104 to understand the Node working directory, reproduce with the provided Robot Framework case, and verify that a relative HAR path is written under outputdir.
Written by the indexing model from the issue text.
Description
A relative recordHar path is passed to the Node side verbatim and is resolved against the Node process's working directory — the wrapper directory inside the installed package. The HAR file is written there instead of under ${OUTPUTDIR}.
This affects ordinary Robot Framework runs, not only keywords called from Python. recordHar never passes through outputdir, so an absolute ${OUTPUTDIR} does not protect it.
Reproduce
*** Settings ***
Library Browser
*** Test Cases ***
Record Har With A Relative Path
New Browser webkit headless=True
New Context recordHar={"path": "relative_from_robot.har"}
New Page ${PAGE_URL}
Get Title == HAR lab
Close Context
Close Browser ALL
Run with robot --outputdir out har.robot. Observed:
Browser/wrapper/relative_from_robot.har 1540 bytes <- actual location
out/ <- no .har anywhere
<cwd>/ <- no .har
The test passes, so nothing signals that the file went somewhere unexpected. In a normal (non-editable) install this writes into site-packages.
Cause
recordHar is never touched on the Python side — it appears only in the keyword signature and documentation (Browser/keywords/playwright_state.py:607,649,752) and is forwarded to Node as given. The Node process runs with cwd=self._browser_wrapper_dir (Browser/playwright.py:280, passed to Popen at :104).
Compare recordVideo, which is resolved before being sent (Browser/keywords/playwright_state.py:948-960) and therefore behaves correctly.
Suggested fix
Resolve the recordHar path in _set_context_options the same way recordVideo's directory is resolved, so a relative path lands under outputdir.
Environment
Browser 20.3.0, Robot Framework 7.4.1, Python 3.14.7, macOS, webkit.
- Dominant language
- Python
- Stars
- 655
- Forks
- 147
- Avg merge
- 5h 33m
- Merged PRs (30d)
- 64
Contributor 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 MarketSquare/robotframework-browser
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
priority: medium
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
priority: medium
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
MarketSquare/robotframework-browser#5251 · 1 comment ·
-
acknowledge enhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
All issues in MarketSquare/robotframework-browser
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100