How to create laravel dusk test from registration page?

create laravel RegisterTest class using below artisan command:

php artisan dusk:make RegisterTest

namespace Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class RegisterTest extends DuskTestCase
     * A Dusk test for user registration page
     * @return void
    public function testUserRegistration()
        $this->browse(function (Browser $browser) {
            $browser->visit('/')  //go to home page
                    ->clickLink('Register') //click on the register link
                    ->assertSee('Register') //see Register text on the homepage
                    ->value('#name', 'test') //fill name  text field with test1
                    ->value('#email', '[email protected]')  //fill email text field with [email protected]
                    ->value('#password','12345678') //fill password text field with 12345678
                    ->value('#password-confirm', '12345678') //fill confirm password text field with 12345678
                    ->click('button[type="submit"]') //click on submit button 
                    ->assertPathIs('/home')     //check if path is /home
                    ->assertSee('You are logged In!');  //check if 'You are logged In!' text is there on the page.

Now run below command:

php artisan dusk

Leave a Comment

Your email address will not be published. Required fields are marked *