1

I have installed dusk for Laravel and since the beginning all the tests have failed. Instead of viewing the page that I want they all return a 404 error.

In order to find out what URL the test is trying to go instead of the one that I want I set up a custom 404 page and put the following code in it:

$_SERVER['REQUEST_URI']

Now the test return the URL that it tries to get and I found that it adds a "/session" to the end of the URL for example if I try to check:

'http://localhost/', DesiredCapabilities::chrome()

The test returns

<p>The requested URL /session was not found on this server.</p>

If I set the URL like this:

'http://localhost/fortest', DesiredCapabilities::chrome()

The test will return:

<p>The requested URL /fortest/session was not found on this server.</p>

I don't know if this has something with Laravel/dusk or PHPUnit or Selenium. Any help appreciated.

user7432810
  • 655
  • 3
  • 11
  • 24

1 Answers1

1

As pointed out in my answer to your previous question it is important to configure the APP_URL to match your local development environment.

/sessions is usually the default session file location when using the native session driver.

For the start create the remote web driver instance with the default Selenium server URL and port:

'http://localhost:9515', DesiredCapabilities::chrome()

Then run your first test located in Browser/ExampleTest.php and validate the current URL.

You can quickly dump the current URL like this:

public function testBasicExample() {

    $this->browse( function ( Browser $browser ) {
        $browser->visit( '/' );
        var_dump( $browser->driver->getCurrentURL() );
    } );

}
Sven
  • 1,450
  • 3
  • 33
  • 58