You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JavaScript prompt (window-based alert with input) auto-closes in CodeceptJS with Playwright + BDD — how to handle it? #5050
I'm trying to handle a JavaScript prompt (window-based alert with input) dialog and input some text before accepting it. But the prompt seems to be automatically closing before I can interact with it, and the test just moves to the next step.
Any idea how to handle this properly or prevent it from being auto-dismissed? Example code or tips would be really helpful. Thanks!
im using Codeceptjs with playwright helper and BDD
In my case (reloading of a page in a text editor causes a browser alert and I need to handle it) the following stuff works for me. I'm using traditional Playwright tests (non BDD).
But not sure about your "window-based alert with input".
Scenario("Reload the page and confirm to stay in the editor",()=>{// Automatically cancel the popupI.amCancellingPopups();// Reload page// Note we can't use I.refreshPage() here, because it waits for the page to be fully loaded, but in this case the page loading is blocked by the popupI.executeScript(()=>{location.reload();});// This only cleans up the popup in CodeceptJS stateI.cancelPopup();I.seeElement(buttonsFragment.save);});Scenario("Reload the page and confirm to leave the editor",()=>{// Automatically accept the popupI.amAcceptingPopups();// Reload pageI.executeScript(()=>{location.reload();});// This only cleans up the popup in CodeceptJS stateI.acceptPopup();// Verify we are on the iPlanner pageI.seeElement(tipCommonPage.header);// Verify the Edit instrument dialog is closedI.dontSeeElement(buttonsFragment.save);});
Activity
mirao commentedon Sep 19, 2025
The automatic dismissing seems to be Playwright feature: https://playwright.dev/docs/dialogs#alert-confirm-prompt-dialogs
In my case (reloading of a page in a text editor causes a browser alert and I need to handle it) the following stuff works for me. I'm using traditional Playwright tests (non BDD).
But not sure about your "window-based alert with input".
github-actions commentedon Dec 19, 2025
This issue is stale because it has been open for 90 days with no activity.