Dismiss browser alert window when script is running in headed mode

I have a script where opening URL redirects to login screen. However, before login screen, it displays blank page with alert window (like on screenshot).
K6GUI-cant-close-alert-window

If I run script in headless mode “K6_BROWSER_HEADLESS=true” this alert window gets dismissed and script runs successfully.
However, if I try “K6_BROWSER_HEADLESS=false”, script fails.
I tried to dismiss it using keyboard “Escape” button but that doesn’t work either.

Is there any way to close alert window when it is running in “K6_BROWSER_HEADLESS=false” mode?

export default async function () {
  
  const page = browser.newPage();

  try {    
    page.goto('https://www.XXXXXX.com/YYYYYY');
    sleep(3);

//    keyboard.press('Escape');  // ERRO[0006] Uncaught (in promise) ReferenceError: keyboard is not defined
      page.keyboard.press('Escape'); // ERRO[0038] Uncaught (in promise) GoError: typing "AAAAA" in "input[name=\"usr\"]": timed out after 30s
      sleep(3);

      page.locator('input[name="usr"]').type('AAAAA');
      page.locator('input[name="pass"]').type('BBBBB');

      const submitButton = page.locator('//*[@id="SignInButton"]');
      await Promise.all([page.waitForNavigation(), submitButton.click()]);
      sleep(3);

      page.screenshot({ path: 'screenshots/screenshot.png' });

   } finally {
     page.close();
   }
}

Hi @sonia2024,

Sorry for the delay in getting back to you. So this isn’t a dialog box since the browser module currently dismisses them automatically. I’d need to reproduce the issue on my end to be able to assist you to work out whether we have a workaround or whether we need a new feature. Could you share a test script that points to a publicly accessible website please?

Best,
Ankur