Working out what events are fired when developing scripts

not sure where to ask, but I’m having all sorts of timing issues with certain WaitForSelectors timing out / completing before the dom is loaded etc. slowmo seems to help, is there a way to set logging or something to see what events are firing as i’m having real issues getting a simple script to work.
ie. enter username, enter password, goto new page.

Hi @DangerMouse,

Have you tried the fillform example as it exactly does what you need for.

You can enable logging by adding an environment flag to the xk6-browser command as follows: XK6_BROWSER_LOG=debug or XK6_BROWSER_LOG=trace.


$ XK6_BROWSER_LOG=debug xk6-browser run ./script.js 


thanks for this, its kinda helping seeing whats going on.

The real problem i have is that when i run in headless mode, it works fine, but when i have a browser visible it just hangs after doing a
on a submit button to enter the username
It appears to be on the second page of the app, it doesn’t come back to the extension properly.

I’ll just have to do screenshots and run in headless mode, but its a bit strange.

@DangerMouse Make sure you’re properly waiting for the page to load or for the element to be present on the page before calling page.$(locator).click().

For example, this might work better:


If you’re testing a SPA then Page.waitForSelector() is a good fit, since the page will be loaded dynamically. But if you’re testing a traditional MPA and you expect a frame navigation then Page.waitForNavigation() would work better.

If you can share a minimal script that we can run, we might be able to help you further.