I’m trying to run some K6 browser tests in Github Actions but getting an error:
time="2023-12-13T10:08:56Z" level=error msg="error building browser on IterStart: launching browser: exec: no command at browserFunction (file:///github/workspace/test.js:28:7(0))"
I can run http tests (ie. not using the browser) just fine in the Action and I can confirm that the browser test runs fine locally
The code I’m using is K6 boilerplate. Test file:
import { browser } from "k6/experimental/browser";
import { check, sleep } from "k6";
import http from "k6/http";
export const options = {
scenarios: {
ui: {
executor: "shared-iterations",
exec: "browserFunction",
options: {
browser: {
type: "chromium",
},
},
},
// http: {
// executor: "constant-vus",
// exec: "httpFunction",
// vus: 10,
// duration: "5s",
// },
},
thresholds: {
checks: ["rate==1.0"],
},
};
export async function browserFunction() {
const context = browser.newContext();
const page = context.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();
}
}
export async function httpFunction() {
const res = http.get("https://httpbin.test.k6.io/");
check(res, { "status was 200": (r) => r.status == 200 });
sleep(1);
}
Action file:
name: Main Workflow
on: [push]
jobs:
build:
name: Run k6 test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run k6 local test
uses: grafana/k6-action@v0.3.1
with:
filename: test.js
I have tested this on two machines in separate Github repos respectively (work and personal) but using the same Github account, with the same error occuring. Is K6 unable to find the browser when running in the workflow?