grafana / xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
337 stars 42 forks source link

unknown module: k6/x/browser #112

Closed QAInsights closed 2 years ago

QAInsights commented 2 years ago

I installed k6 and xk6 and tried the sample code. But I am getting the below error in Window 10.

image

import launcher from "k6/x/browser";

export default function() {
    const browser = launcher.launch('chromium', { headless: false });
    const context = browser.newContext();
    const page = context.newPage();
    page.goto('http://whatsmyuseragent.org/', { waitUntil: 'load' });
    const dimensions = page.evaluate(() => {
        return {
            width: document.documentElement.clientWidth,
            height: document.documentElement.clientHeight,
            deviceScaleFactor: window.devicePixelRatio
        };
    });
    console.log(JSON.stringify(dimensions));
    page.close();
    browser.close();
}
LaserPhaser commented 2 years ago

you have to use newly built xk6 binary to be able to run it.

imiric commented 2 years ago

Like @LaserPhaser says, you need to run the examples with the binary built by xk6. See the installation instructions in the README or download the pre-compiled binary from the Releases page.

I'll clarify the usage instructions in the README since that might not be clear enough.

QAInsights commented 2 years ago

@imiric @LaserPhaser I built the binary, but when I tried to run the script, it prompts to open the application. I do have Chrome installed on my system. But it works fine in git bash.

image

imiric commented 2 years ago

@QAInsights Please use the community forum for support questions. GitHub issues are for tracking bugs or suggesting features.

There are other Windows users on the forum who can help you with your issue.

QAInsights commented 2 years ago

@imiric this is not a support question, it's an issue :) please check.