Closed beliolfa closed 6 years ago
You can use $browser->acceptDialog();
Can this be closed?
$browser->dismissDialog()
= press Cancel (if confirmation)
$browser->acceptDialog()
= press OK
I have something like this:
$this->browse(function (Browser $browser) {
$browser->visit('/')
->type('name', 'Jonh')
->type('email', '')
->type('phone', '555-555-5555')
->click('.btn-next')
->assertDialogOpened("Email is required");
});
When I run the tests I see this error:
1) Tests\Browser\PickupFormTest::testMustFillRequiredToProceed
Facebook\WebDriver\Exception\UnexpectedAlertOpenException: unexpected alert open: {Alert text : Email is required
Please provide a valid email}
Shouldn't assertDialogOpened()
expect the alert to open and verify the correct text? Why is it throwing an UnexpectedAlertOpenException
?
I think if you do below it will pass (added acceptDialog
at the end)
$browser->visit('/')
->type('name', 'Jonh')
->type('email', '')
->type('phone', '555-555-5555')
->click('.btn-next')
->assertDialogOpened("Email is required")
->acceptDialog();
I think this is related to Chrome's bug itself. The bug has been fixed, but it hasn't been released yet.
Basically you can't verify the message in the dialog as the dialog has been closed automatically.
For now, you can either use js library for the popup or just test what happens after the dialog was closed.
Bug ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=718235
Having the same issue and using ->acceptDialog();
didn't work.
Please post the relevant parts of your code.
although this is closed, I came across this because I was having some issues with this. It turned out that the message I had in my assertDialogOpened
didn't exactly match the message that was being displayed, which was then triggering the exception regardless of any other actions I had in place.
Long and short of it, make sure you are accepting a dialog with the correct text.
Hi All, maybe you need $browser->waitForDialog(5);
to wait until alert dialog appears.
Hi All, maybe you need $browser->waitForDialog(5); to wait until alert dialog appears.
Adding a slight delay did the trick, even though to my eyes the alert comes up instantly after the previous action. My solution:
$browser->waitForDialog(1)
->assertDialogOpened('Alert text here')
->acceptDialog();
I am getting this exception when I click the delete button
How could I expect a confirm alert in screen and then press OK?