xk6-browser
xk6-browser copied to clipboard
Intermittent issues occur when using page.waitForNavigation() after element.click()
In one of our examples, we have:
// In the following Promise.all the tails locator clicks
// on the tails button by using the locator's selector.
// Since clicking on each button causes page navigation,
// waitForNavigation is needed -- this is because the page
// won't be ready until the navigation completes.
// Setting up the waitForNavigation first before the click
// is important to avoid race conditions.
Promise.all([
page.waitForNavigation(),
tails.click(),
Promise.all
concurrently runs the above promises so tails.click()
can be written first before page.waitForNavigation()
.
However, I noticed if I pass in the slowMo
option to chromium.launch()
, the test fails with the following error depending on the value passed to slowMo
.
ERRO[0030] communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF category=cdp elapsed="0 ms" goroutine=85
ERRO[0033] Uncaught (in promise) getting inner text of "//p[starts-with(text(),'Your bet: ')]": getting new document handle: getting document element handle: sending a message to browser: websocket: close 1006 (abnormal closure): unexpected EOF executor=per-vu-iterations scenario=default
If the value of slowMo
is set to 100ms
, the test passes but if it's >120ms
, then the test fails with the above error. It seems that there is a race condition somewhere that we need to address.