K6 operator doesn't support browser module

Is k6-operator able to execute a test case that contains k6 browser module? I see this error msg from the pod:

"error building browser on IterStart: finding browser executable: k6 couldn't detect google chrome or a chromium-supported browser on this system at file:///test/browser.js:20:15(0)"

The test script:

import { browser } from "k6/experimental/browser";
import { check } from "k6";

export const options = {
  scenarios: {
    ui: {
      executor: "shared-iterations",
      options: {
        browser: {
          type: "chromium",
        },
      },
    },
  },
  thresholds: {
    checks: ["rate==1.0"],
  },
};

export default async function () {
  const page = browser.newPage();

  try {
    await page.goto("https://test.k6.io/my_messages.php");

    page.locator('input[name="login"]').type("admin");
    page.locator('input[name="password"]').type("123");

    const submitButton = page.locator('input[type="submit"]');

    await Promise.all([page.waitForNavigation(), submitButton.click()]);

    check(page, {
      header: (p) => p.locator("h2").textContent() == "Welcome, admin!",
    });
  } finally {
    page.close();
  }
}

The trigger file:

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: run-k6
spec:
  parallelism: 1
  script:
    configMap:
      name: browser
      file: browser.js

Hi @zzhao2022

I think you should use a custom docker image in the yaml file which contains chrome.

Hi @zzhao2022 and @bandorko

I also thought to add a custom docker image to the file, but found out that it is not needed.
Instead I added a k6 grafana image with browser

runner:
    image: grafana/k6:latest-with-browser

to the yaml file. That made it possible to run my k6 browser tests with k6 worker.

2 Likes

@nataschas I tried with passing above image, but I see browser test are not getting triggered after initializer pod is started, can you please share the k6-operator steps you did to make it work?

Thanks,
Temothy