acceptDialog with laravel dusk

Posted 4 months ago by fconstans


I am trying to test a functionality to disable/enable a resource. It detects correctly the dialog but acceptDialog() seems to not work correctly.

The test is like:

                ->resize(1440, 3000)
                ->visitRoute('route', ['id' => $id])
                ->assertDialogOpened('Are you sure you wish to activate/deactivate this resource?')

If I don't use the acceptDialog, an exception is raised -> Facebook\WebDriver\Exception\UnexpectedAlertOpenException

But using the acceptDialog seems like the dialog is dismissed instead of being accepted, because It stays on the same page ( notice the pause function to ensure enough time to change the page).

I get a screenshot of the page like the button was never clicked and the dialog accepted. Can't take an screenshoot when the dialog is displayed because I get an UnexpetedAlertOpenException.

The html code of the element with the state-resource id is:

<button style="display:inline" class="submit small text_only has_text" id="state-resource"  onclick="return confirm('Are you sure you wish to activate/deactivate this resource?')">

Somebody knows why this test doesn't work?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.