I'm trying to run some tests on a Laravel project but even the most basic tests won't work.
Configuration:
- Laravel 5.5
- Dusk for tests
- MacOS High Sierra
- PHPStorm
I would like to test the login page.
First of all, I know I have to add an attribute to the <button>
in resources->views->forms->user->login.blade.php
:
My code:
<div class="submit-button-container">
<button class="button" dusk="login-button">Connexion</button>
</div>
Then I create the LoginTest.php
file:
<?php
namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class LoginTest extends DuskTestCase
{
/**
* @throws \Exception
* @throws \Throwable
*/
public function testExample()
{
$this->browse( function (Browser $browser) {
$browser->visit('se-connecter') //login page
->click('@login-button'); //click the login button
});
}
}
When I run the command line php artisan dusk
I get this error :**
The most important message is : no such element: Unable to locate element: {"method":"css selector","selector":"body [dusk="login-button"]"}
MY QUESTION IS:
- How do I define a selector as shown on the error message ?
Aucun commentaire:
Enregistrer un commentaire