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.

4

1 回答 1

1

正如我在对您之前的问题的回答中所指出的,配置APP_URL以匹配您的本地开发环境非常重要。

/sessions通常是使用本机会话驱动程序时的默认会话文件位置。

首先使用默认的 Selenium 服务器 URL 和端口创建远程 Web 驱动程序实例:

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

然后运行您的第一个测试Browser/ExampleTest.php并验证当前 URL。

您可以像这样快速转储当前 URL:

public function testBasicExample() {

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

}
于 2017-07-31T09:47:15.343 回答