acceptDialog with laravel dusk

Posted 4 months ago by fconstans

Hi,

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:

$browser->loginAs($user)
                ->resize(1440, 3000)
                ->visitRoute('route', ['id' => $id])
                ->assertSee('Active')
                ->click('#state-resource')
                ->pause(20)
                ->assertDialogOpened('Are you sure you wish to activate/deactivate this resource?')
                ->acceptDialog()
                ->pause(1000)
                ->assertSee('Inactive')
                ->restoreSize();

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?')">
    Deactivate
</button>

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

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.