I tried to get the id from my html to used by click
method in unit testing laravel.
here is my html using blade:
<td>
<form class="form-horizontal" method="post" action="{{ action('AdminWeb\UserController@toggleActivateStatus', $user->id) }}">
{{ csrf_field() }}
<button id="user{{$user->id}}" class="btn btn-sm {{ $user->status == 'active' ? 'btn-danger' : 'btn-success' }}" type="submit">{{ $user->status == 'active' ? 'Deactivate' : 'Activate' }}</button>
</form>
</td>
notice that I generate the id element in <button>
using id="user{{$user->id}}"
so I tried to get that id for example id=user3
in my test class like this :
public function testActivateUser()
{
$this->visit('users')
->click('user3')
->seePageis('users');
}
but I unable to get it :
UserControllerTest::testActivateUser
InvalidArgumentException: Could not find a link with a body, name, or ID attribute of [user3].
any help? thanks.