So I tried to run my test in ‘headless’ mode to see if that changes things. Not sure if things like dialogs / alerts will be ignored in headless mode??
I do however get this error:
ERRO[0045] Uncaught (in promise) GoError: clicking on "input[type=\"button\"]": execution context changed; most likely because of a navigation: GoError
Thanks for the question. Unfortunately we don’t have page.on implemented yet in xk6-browser, and we can’t yet interact with dialog boxes. I’ve created issue #655 which you can follow and keep track of the progress.
So basically the first page has a form which I complete, then I ‘click’ the Next button which loads another page (with the pop-up alert) which I then also have to ‘click’ on the input button to complete the transaction.
I’m assuming the “execution context changed…” error is because of the dialog but I could be wrong.
I’ve used the exact same script as the one you’ve provided. Instead of an execution context changed… error, in my test it eventually times out which i assume is while it’s waiting for a selector that matches input[type="button"] which doesn’t appear because of the dialog box (even in headless mode).
The only way i could replicate the issue is when I ran:
I think I won’t be able to replicate the issue unless I have access to the same website that you are testing against, as well as knowing some details of which OS you are running.
We’ve just merged in a change into main that will dismiss dialog boxes automatically. Please take a look if you get a chance and let us know if this unblocks your test.
You can build your own binary from main by following these steps (assuming you have go installed):
# Install xk6
go install go.k6.io/xk6/cmd/xk6@latest
# Build the xk6-browser binary (for Unix based systems)
xk6 build --output xk6-browser --with github.com/grafana/xk6-browser@main
# Build the xk6-browser binary (for Windows based systems)
xk6 build --output xk6-browser.exe --with github.com/grafana/xk6-browser@main
After running the commands you should have a binary called xk6-browser, and you should be able to use that to run your test.
This still seems to be an issue. The latest version of K6 (v0.52.0 (commit/20f8febb5b, go1.22.4, windows/amd64) will dismiss the dialog box but it doesn’t seem to return a value properly. This is a blocker for using K6 when websites utilize methods like confirm() or prompt(). Seems the onclick handler defined doesn’t process anything after the dismisal by K6. I’ve had to revert to playwright to accept() these types of dialogs properly. The issues (665 and 663) above seem to only cover dismisal in a specific scenario (headful and beforeunload).
Any chance I am missing this ability in the current version of K6? (e.g. page.on() approach)