acceptDialog with laravel dusk

Posted 7 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.

Reply to

Use Markdown with GitHub-flavored code blocks.