K6-browser not compatible with navigator.mediaDevices.getUserMedia?

Hello,
I’m trying to test a webphone with K6 experimental browser. Unfortunately, it seems that it does not work. K6 browser return an error (“NotSupportedError”) on function getUserMedia().
Could you tell me if it is a bug or if it is a feature not supported at this time ?
Already checked : https used, microphone authorization in Chrome (I also test with K6 browser argument “auto-accept-camera-and-microphone-capture”).

Here is step to reproduce the error, web page tested :

<html><head><title>My Webphone</title></head>
<body><script>
navigator.mediaDevices.getUserMedia({audio: true, video: false}).catch(function(t) {
                                console.log("getusermedia failed : ", t);
                            });
</script></body>

and the K6 script :

import { browser, devices } from 'k6/experimental/browser';
import { check } from 'k6';
export const options = {
  httpDebug: 'full',
  scenarios: {
 webrtc: {
        executor: 'shared-iterations',
        exec: 'webrtc',
        iterations: 1,
        options: {
          browser: {
            type: 'chromium',
} } } }}

export async function webrtc() {
  const context = browser.newContext();
  const page = context.newPage();
  try {
    await page.goto("https://<my_webphone_page>", {timeout: 10000});
    page.waitForTimeout(10000);
  } finally {
    page.close();
  }
}

When I run the test, I got this error printed by my script :

INFO[0002] "getusermedia failed : " {"code":9,"message":"Not supported","name":"NotSupportedError"}  browser_source=console-api source=browser

Hi @fxou,

Welcome to the forum!

This error doesn’t come from the browser module. It comes from the browser, and the browser module reports it. The problem might be related to the fact that Chromium doesn’t allow using getUserMedia out of HTTPS connections. Please check out this answer to learn more.

Hope this helps.

1 Like

Hello @inancgumus ,
Thanks for your answer. I’ve already checked that I’m using https:// as I wrote in my previous message. Also, when I put exactly the same URL in Chrome or another browser, it works (ie : no error message in console logs). Following your answer, I’m continue to investigate at Chromium side.

1 Like