Published 1 month 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:
$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?
I'm using the version 3.0.8 of laravel/dusk, looked at it and seems the last one.
Just upgraded chromium from 65.0.3325.181-0ubuntu1 to 66.0.3359.181-0ubuntu0.18.04.1 on the homestead machine, with the same result.
I don't know what else check or how I can debug this behaviour.
I think the problem is with the form being submitted.
The button itself is inside a form with serveral data.
Works in both cases when there is 'human' interaction.
I say this because this platform has a really old jQuery version and I have read that some instructions make dusk inject jQuery library so maybe is there some version conflict?