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).
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();
}
}