Version
1.58.0
Steps to reproduce
- Clone my repo at https://github.com/fwdekker/playwright-python-har-bug
pip install -r requirements.txt
python main.py
- After the web page is loaded, manually close the browser window. Either close the tab, or close the window.
- Check the contents of the
out/ directory.
Expected behavior
The file out/recording.har is created.
Actual behavior
The file out/recording.har is not created.
Additional context
I understand that the context must be closed gracefully in order to ensure the .har is created. I expected await context.close() to be sufficient, but apparently adding an event listener for close changes things.
I do not encounter this bug when using the equivalent code on a non-persistent context.
Removing the line await event.wait() results in the recording.har being created correctly. However, this line is necessary to allow the user to manually decide when to close the window.
Environment
- Operating System: Windows 11
- CPU: amd64
- Browser: Chromium and Firefox. Not tested on Webkit
- Python Version: 3.14
Version
1.58.0
Steps to reproduce
pip install -r requirements.txtpython main.pyout/directory.Expected behavior
The file
out/recording.haris created.Actual behavior
The file
out/recording.haris not created.Additional context
I understand that the context must be closed gracefully in order to ensure the
.haris created. I expectedawait context.close()to be sufficient, but apparently adding an event listener forclosechanges things.I do not encounter this bug when using the equivalent code on a non-persistent context.
Removing the line
await event.wait()results in therecording.harbeing created correctly. However, this line is necessary to allow the user to manually decide when to close the window.Environment