Rayrun
โ† Back to Discord Forum

Video codecs in browsers

Hi all, I'm currently testing a browser application that includes a video player. Unfortunately, playwright browsers don't have the necessary codecs to play videos. Currently, I'm using my local Chrome installation with channel: chrome in the project. Now, I would like to also test it in Firefox.

When I run my test in Firefox, a message appears indicating that Nightly is downloading some necessary components. After waiting for some time, the video starts to play. Is there a way to download and persist these components, so they don't need to be installed every time? It would be great to find a solution to install them once and for all. Alternatively, it would be acceptable to download them once per test run and then reuse them for all the tests in the suite.

Additionally, I have a bonus question: Can this be done for Chromium as well, so I can stop using the locally installed browser with the channel option?

This thread is trying to answer question "Is there a way to download and persist necessary components for video playback in Firefox and Chromium, so they don't need to be installed every time?"

20 replies

Heyy I'm having this problem as well.. using, how did you manage to work on chrome? for me it always launcheds chromiun, even though Im using channel "chrome" from the terminal or ui, sorry for hijacking your question ๐Ÿ˜…

@madtin I have a project setup in playwright.config file. This is working for me:

projects: [
        {
            name: 'chrome',
            use: {
                channel: 'chrome',
            },
        }]
@darill: Yeah using the same... but looking at the traces it says "chromium" and it fails to playback a stream since codecs are not present.

Yeah using the same... but looking at the traces it says "chromium" and it fails to playback a stream since codecs are not present.

image.png

Launching the tests from the vs code extension it works thought. Since it launches my local chrome binary as expected

Do you tried running it from terminal?

I tried channeled chrome and chromium and engine is everytime "chromium". But when I run it on Chrome, the test works

๐Ÿ˜ฐ

mine doesn't because of a missing component...

Hmmm, so I hope someone has a solution for my original question ๐Ÿ˜„

Any ideas for my original question?

AFAIK It's not possible to install those on chromium, and for the firefox part, the only problem is that "installing components" part?

Ideas for the original question:

  1. Can you try with playwright docker image, and see if it's better there?
  2. Do you need to actually test the video player? If not, you should it be remove it(by blocking the request, or just removing the element from the dom?).
@madtin: Yes - it takes a long time to install the components. In headed mode I tried to wait long enough and the video finally started. But when I try it in headless mode, it fails in most cases (even with ridiculous timeouts like 5 mins). But it is weird, because sometimes a test takes like 1 minute and passes. But in another run it timesout

Yes - it takes a long time to install the components. In headed mode I tried to wait long enough and the video finally started. But when I try it in headless mode, it fails in most cases (even with ridiculous timeouts like 5 mins). But it is weird, because sometimes a test takes like 1 minute and passes. But in another run it timesout

@oci1458: Thanks, I will try the docker image. And yes, I need to test the videoplayer too.

Thanks, I will try the docker image. And yes, I need to test the videoplayer too.

It works the same with the docker image :/

I have the same issue, video cannot be played in chrome. Is there any solution for it ?

Doesn't using a channel for Chrome do the trick? https://playwright.dev/docs/browsers#google-chrome--microsoft-edge

Nope.. I tried channel 'chrome' and even tried using the desktop chrome by providing the location of the executable.

refactoreric

Are you using @playwright/test or is this a script? In case of a test, what does your configuration (playwright.config.ts/js) look like? In case of a script, what does the code for launching the browser, opening the browser context and the page look like?

Answer

Sure, you can manage browser downloads for video playback testing in Playwright.

Downloading Browsers

By default, Playwright downloads the latest Chromium version. But, you can specify a different version or browser by setting environment variables.

To download browsers into a specific location, use the PLAYWRIGHT_BROWSERS_PATH environment variable. Here's how:

PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install

Skipping Browser Downloads

If you manage browser binaries separately, you can skip browser downloads with the PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD variable:

PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx playwright install

Media Codecs Support

Remember, Chromium may not have all the codecs bundled with Google Chrome or Microsoft Edge due to licensing. If your site relies on specific media codecs, it's recommended to use official channels such as Google Chrome or Microsoft Edge for testing.

Enterprise Environments

For enterprise environments with policies that restrict certain capabilities or require mandatory extensions, using bundled Chromium for local testing is recommended.

Firefox

Playwright's Firefox version matches the recent Firefox Stable build. Playwright does not work with branded versions of Firefox and instead relies on patches. Therefore, it is recommended to test against the recent Firefox Stable build when using Playwright with Firefox.

In short, Playwright gives you flexibility in managing browsers for testing video playback. You can specify a custom location for browser downloads, skip browser downloads altogether, and choose between different browsers based on their capabilities and your specific testing requirements.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].