-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
The following error is being logged when attempting to save videos from my pytest-based Playwright tests in both headless and headful mode:
Error dispatching the event Traceback (most recent call last):
File "venv/lib/python3.8/site-packages/playwright/connection.py", line 204, in _dispatch
g.switch(self._replace_guids_with_channels(params))
File "venv/lib/python3.8/site-packages/playwright/page.py", line 214, in <lambda>
lambda params: cast(Video, self.video)._set_relative_path(
AttributeError: 'NoneType' object has no attribute '_set_relative_path'
The videos are still saved successfully, however, so as far as I can tell the error is only cosmetic. This only happens when using the recordVideo parameter of browser.newContext(). If I set videosPath
instead, there is no error.
According to the docstrings for videosPath and videoSize, recordVideo takes precedence and should be used instead, e.g.:
NOTE Use
recordVideo
instead, it takes precedence overvideoSize
. Specifies dimensions of the automatically recorded video. Can only be used ifvideosPath
is set. If not specified the size will be equal toviewport
. Ifviewport
is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
For now, I can just use videosPath to avoid errors and replace it with recordVideo if this issue is resolved. Here's the fixture where I created the new context:
@fixture(scope='function')
def context(browser: Browser) -> Generator[BrowserContext, None, None]:
context = browser.newContext(ignoreHTTPSErrors=True, acceptDownloads=True, recordVideo={'dir': 'playwrightvids'})
context.setDefaultTimeout(10000)
yield context
context.close()