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.
A relative
recordHarpath 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.
recordHarnever passes throughoutputdir, so an absolute${OUTPUTDIR}does not protect it.Reproduce
Run with
robot --outputdir out har.robot. Observed:The test passes, so nothing signals that the file went somewhere unexpected. In a normal (non-editable) install this writes into
site-packages.Cause
recordHaris 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 withcwd=self._browser_wrapper_dir(Browser/playwright.py:280, passed toPopenat:104).Compare
recordVideo, which is resolved before being sent (Browser/keywords/playwright_state.py:948-960) and therefore behaves correctly.Suggested fix
Resolve the
recordHarpath in_set_context_optionsthe same wayrecordVideo's directory is resolved, so a relative path lands underoutputdir.Environment
Browser 20.3.0, Robot Framework 7.4.1, Python 3.14.7, macOS, webkit.