mardi 6 septembre 2016

How to get Id inside for testing using click method

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="">
        
        <button id="user" class="btn btn-sm " type="submit"></button>
    </form>
</td>

notice that I generate the id element in <button> using id="user"

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.

Aucun commentaire:

Enregistrer un commentaire