FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Error when saving video recording files using recordVideo context param · Issue #334 · microsoft/playwright-python · GitHub

Repository navigation

Error when saving video recording files using recordVideo context param #334

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 over videoSize. Specifies dimensions of the automatically recorded video. Can only be used if videosPath is set. If not specified the size will be equal to viewport. If viewport 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()

Activity

  1. strozzapreti commented on Dec 2, 2020

    Author

    Y'all work fast. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL