-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] page.waitForEvent('dialog') is not working #4737
Comments
const [dialog] = await Promise.all([
page.waitForEvent('dialog'),
page.click("id=searchBtn") // <-- this never resolves, because dialog is hanging.
]);
let msg = dialog.message(); // <-- so you don't event get here |
I encountered the same problem with |
Hi, I think I'm experiencing a similar issue with:
Which is giving me:
In this case, it looks like the click in the Promise is resolved because the navigation happens but we still timeout and the rest of the code isn't executed. See logs:
Environment:
|
@VincentDondain Do you have a dialog (like an alert box) on your page? Try putting the following at the start of your script, does it help? page.on('dialog', dialog => dialog.dismiss()); |
Please reopen if still an issue |
Context:
Code Snippet
Describe the bug
I have multiple alerts in page in different situations. I tried with below code. It successfully clicked on searchBtn element and displayed alert. After that I get an error stating that searchBtn is failed. But it clicks and alert is displayed.
page.click: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "id=searchBtn"
selector resolved to visible <input type="button" id="searchBtn" title="Search" name…/>
=========================== logs ===========================
After that I have used below code and it works on clicking in button.
page.on('dialog', async dialog => {
if (dialog.message() === "from place required") {
console.log("Validation successful");
}
await dialog.accept();
});
What is the problem in First code snippet? Why is that not working? Why is it giving incorrect log info even after clicking on button? What is the purpose of page.waitForEvent('dialog')?
The text was updated successfully, but these errors were encountered: