0

I am following the Laravel Documentation (https://laravel.com/docs/5.4/dusk) to create browser tests for my application.

After some trials, I got Dusk to run. It runs only when --headless mode is used -- otherwise, PHP unit hangs without any output.

Anyway, I got the following error message when trying to test the login page:

Facebook\WebDriver\Exception\UnknownServerException: unknown error: 
an X display is required for keycode conversions, consider using Xvfb

The code is nothing special, just typing in the fields:

    $this->browse(function ($browser) use ($user) {

        $browser->visit('/login')
                ->type('email', $user->email)
                ->type('password', 'secret')
                ->press('Login')
                ->assertPathIs('/home');
    });

I am new to testing and any help would be appreciated.

hktang
  • 1,745
  • 21
  • 35

1 Answers1

0

I realize this simple but deadly problem and finally get Dusk working. Hope this will help other newcomers to the world of feature testing with Dusk:

Make sure you run php artisan dusk in your host environment, not in the Laravel Homestead virtual machine.

Before doing that, you might want to make sure:

  1. DB_HOSTin your .env file is set to 192.168.10.10 or whatever you set in your host file that points to your Laravel app in your local development environment.
  2. You don't use extra options for the remoteWebServer, i.e., simply using the default 'http://localhost:9515', DesiredCapabilities::chrome() is enough to get you started.
hktang
  • 1,745
  • 21
  • 35