Xk6 Browser Command Opens Windows 'How Do You Want to Open This File?'

A file ‘xk6-browser’ exists at my working directory, it is approximately 30KB in size.

I’ve created a simple test in a file called browser-test.js
The test attempts to launch a ‘chromium’ browser

When I type ‘./xk6-browser run Browser/browser-test.js’ in PowerShell from my working directory a Windows dialog appears “How do you want to open this file?”, with options such as Adobe, Visual Studio, Notepad, etc.

How should I proceed?

`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('test-site-5', { waitUntil: 'networkidle'});




If I select Chromium from the dialog, it opens a browser at my working directory + ‘xk6-browser’, and redownloads the xk6-browser file

I opened a Bash window and typed the following commands:

go install go.k6.io/xk6/cmd/xk6@latest

go xk6 build --output xk6-browser --with GitHub - grafana/xk6-browser: k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol

Theres about a 28 line print out in Bash, with a 2nd to last line of ‘Build complete xk6-browser’

Now when I type the ‘./xk6-browser run Browser/browser-test.js’ my system no longer produces the unwanted “How do you want to open this file?” dialog.

Hi there!

A file ‘xk6-browser’ exists at my working directory, it is approximately 30KB in size.

Where did you get this file? The xk6-browser binary should be around 30MB in size, not 30KB. Was this a typo?

My hunch is that this was an HTML or text file that you mistakenly downloaded as xk6-browser, which is why Windows was prompting you to open it in a specific program. And it worked fine when you compiled your own binary with xk6.

If you don’t want to compile your own, make sure to download an official Windows binary from our GitHub releases page.

There’s a xk6-browser-<version>-checksums.txt file there you can use to confirm whether you have the correct archive. You can compare that SHA256 checksum with the output of the Get-FileHash cmdlet in PowerShell. You should see something like this:

I should have written 30,058 KB regarding the browser size.

The HASH I’m getting for the xk6-browser file doesn’t match the xk6-browser-v0.2.0-checksums

Then your file is being corrupted while downloading or something is corrupting it locally. There could be many reasons for this. Try using a different network connection. Do you have an antivirus running that could be falsely detecting and corrupting it?

FWIW I tested with the release binary and it works fine for me in PowerShell on Windows 10.

For xk6-browser-v0.2.0-windows-amd64.msi the Get-FileHash is returning 92DACCCF03886F5F1B01CFCD496B96C8844917BED42CC3F7A6DF3B9D95D41D9E
on two separate computers

I’m still new to this feature but as far as I can tell the xk6 browser is starting correctly on my machine.

That’s the same one from xk6-browser-v0.2.0-checksums.txt:

92dacccf03886f5f1b01cfcd496b96c8844917bed42cc3f7a6df3b9d95d41d9e  xk6-browser-v0.2.0-windows-amd64.msi

So all good then.