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'});

page.$('input[name="UserId"]').type('username');
page.$('input[name="Password"]').type('password');
page.$('input[type="submit"]').click();

page.waitForLoadState('networkidle');
page.close();
browser.close();

}`

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.

I’m still facing this issue. I have created the xk6-browser binary in the current working directory using the below commands. But still the XK6 Browser command opens Windows ‘How Do You Want to Open This File?’ popup. Please help on this issue.

Install xk6

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

Build the xk6-browser binary

> xk6 build --output xk6-browser --with github.com/grafana/xk6-browser

Hi @vishvambruth.javagal,

Welcome to the forum!

Firstly, have you seen Imiric’s post in this thread on downloading the official binary and double checking the SHA256 of the downloaded binary to compare it against the one that is listed with the releases? Could be a useful work around if the following answer doesn’t help.

Secondly, I’ve just ran those commands on Windows 11 in powershell, and hit the same issue. I was able to get around this by ensuring that in the xk6 build command we name the output file correctly with .exe. Try this now and let us know if that helps:

xk6 build --output xk6-browser.exe --with github.com/grafana/xk6-browser

Cheers,
Ankur

Hi @ankur, Running the below command fixed the issue. Now I’m not getting the Windows ‘How Do You Want to Open This File?’ popup after running the below command. Thanks for the quick response :slight_smile:

> xk6 build --output xk6-browser.exe --with github.com/grafana/xk6-browser

1 Like