K6 browser is not able to detect new pages

I’m clicking a link on a webpage which opens a new page. k6 is not able to detect the new page. Though context.pages().length returns 2, it doesn’t identify any page other than the original page. So it is not able to navigate & operate on the new page.
Following code snippet can be used to experiment with this.
Can anyone guide if I’m missing something here?

  const page = browser.newPage();
  
  let baseUrl = "https://httpbin.org/"
  await page.goto(baseUrl, {waitUntil: 'load'});
  Logger.info("Home Page title:",page.title())

  const newLinkSelector = page.locator("a[href='https://kennethreitz.org']");
  Logger.info(newLinkSelector.innerText())
  newLinkSelector.click()
  sleep(5)
   
  console.log("Page Count:",context.pages().length);
  const pages = browser.context().pages()
  for (let i in pages){
    console.log(`Title${i}`, pages[i].title())
  }

I am using k6 version k6.exe v0.49.0 (commit/b5328aa782, go1.21.6, windows/amd64)

Hi @sumitbhowmick,

Thanks for bringing this to our attention. Unfortunately it’s a bug in the k6 browser module where by the new tab doesn’t open. We have an open issue for this: Clicking on a link that opens a new tab never navigates to the href link · Issue #827 · grafana/xk6-browser · GitHub which you can follow to see its progress. Please like or add more details to the issue which will help get it prioritised.

Cheers,
Ankur

Hi @ankur , the status of Clicking on a link that opens a new tab never navigates to the href link · Issue #827 · grafana/xk6-browser · GitHub says the issue was fixed by v0.52.0 release from a few days ago. But I am still having the exact same issue @sumitbhowmick reported here in this post.