I have a test where I log in (successfully) and see the page that comes up after. I want to click a button on that page, and was able to get it to work… one time.
Every time since, I get err:read tcp 127.0.0.1:59180->127.0.0.1:59179: wsarecv: An existing connection was forcibly closed by the remote host.
followed by wsURL:"ws://127.0.0.1:59179/devtools/browser/45eb2ea4-db6d-4d80-a4ae-d5d3572e1ba0" sid:8B05ABE458CE3C4F3DA7D0F7A095425E err:context canceled
followed by click "button.cartAddBtn": context canceled
What I’m wondering is if there’s something I’m doing wrong in my code that’s causing it, or if it’s just a thing where it’s flaky and I should just run it until it succeeds.
It’s possible that the page.click('button.cartAddBtn') call is being interrupted by the script or iteration ending too early.
Can you try passing the slowMo option to launcher.launch()? E.g. slowMo: '500ms'.
Also, if the click() triggers a DOM change or navigation, you might want to call page.waitForSelector() after to wait for it to complete before ending the iteration or test run.
There are possibly other issues there, like a race condition between click() and waitForNavigation(), but I don’t think that’s the issue you’re running into.
I’m assuming you’re running xk6-browser v0.4.0, but if you’re comfortable with building your own binary, you might want to try the latest main branch, and let us know if it improves things for you. You can build it with xk6 build --with github.com/grafana/xk6-browser@main. Note that there are some breaking syntax changes, so you’ll have to update your script. See the v0.5.0 release notes we’re currently working on for details. Otherwise, you can wait for v0.5.0 to be released next week and use the pre-built binary.
Awesome - thank you. I will see if I can get some time to try out the 0.5.0 release when it’s out.
Side note: For now, I have a reprieve in that the requirements for my testing changed to omit the page that needed to run a payment processor’s js, so I’m dropping back to regular k6 for now. Love that xk6-browser is aiming for Playwright API compat