I'm running Valet with Laravel 5.4 installed. My dev url is:
http://dusk.dev/
I'm using the default Laravel welcome screen. I then modified the DuskTestCast.php file:
````php
namespace Tests;
use Laravel\DuskTestCase as BaseTestCase;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
return RemoteWebDriver::create(
'http://dusk.dev:9515', DesiredCapabilities::chrome()
);
}
}
````
I run "php artisan dusk" which I get the following:
````
Jordans-MacBook-Pro:dusk jordandalton$ php artisan dusk
PHPUnit 5.7.5 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 1.5 seconds, Memory: 10.00MB
There was 1 failure:
1) Tests\BrowserExampleTest::testBasicExample
Did not see expected text [Laravel] within element [body].
Failed asserting that false is true.
/Users/jordandalton/Code/Projects/dusk/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:140
/Users/jordandalton/Code/Projects/dusk/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:111
/Users/jordandalton/Code/Projects/dusk/tests/Browser/ExampleTest.php:20
/Users/jordandalton/Code/Projects/dusk/vendor/laravel/dusk/src/TestCase.php:84
/Users/jordandalton/Code/Projects/dusk/tests/Browser/ExampleTest.php:21
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
````
I place a logging point in the MakeAssertions.php file in the Dusk vendor folder
````php
namespace Laravel\DuskConcerns;
use Illuminate\Support\Str;
use Facebook\WebDriver\WebDriverBy;
use PHPUnit_Framework_Assert as PHPUnit;
use Facebook\WebDriverException\NoSuchElementException;
trait MakesAssertions
{
/// removed..
/**
* Assert that the given text appears within the given selector.
*
* @param string $selector
* @param string $text
* @return $this
*/
public function assertSeeIn($selector, $text)
{
$fullSelector = $this->resolver->format($selector);
$element = $this->resolver->findOrFail($selector);
\Log::info($element->getText());
PHPUnit::assertTrue(
Str::contains($element->getText(), $text),
"Did not see expected text [{$text}] within element [{$fullSelector}]."
);
return $this;
}
// removed....
}
````
I'm my laravel.log file I see the following:
[2017-01-14 00:43:32] local.INFO: 404 - Not Found
I get the same error regardless of using localhost or dusk.dev with either the chome() and firefox() browser.
Issue is resolved. Leave the RemoteWebDriver::create() to use http://localhost:9515. However, you need to make sure the APP_URL in your .env matches your dev url which in my case was http://dusk.dev.
I am having same problem you described. I have APP_URL set to blog.dev
RemoteWebDriver::create() use http://localhost:9515
I see this in error log:
[
{
"level": "SEVERE",
"message": "http:\/\/localhost\/ - Failed to load resource: the server responded with a status of 404 (Not Found)",
"source": "network",
"timestamp": 1489117992750
},
{
"level": "SEVERE",
"message": "http:\/\/localhost\/favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)",
"source": "network",
"timestamp": 1489117992779
}
]
I dont know why it hits localhost? my dev env is blog.dev and its set in config/app.php , do i need to set it somewhere else?
Does your env say this?
APP_URL=http://blog.dev
yes it does
I dont know if this is expected:
i am running php storm in full view and having terminal window open in php storm. So i am running php artisan dusk within full windowed php storm
whenever i run php artisan dusk, very quickly php storm is minimized, chrome browser window opens with http://localhost and 404 in the window, but its very very fast cant read if tehre is something more, then dissapears and php storm does not come back into full screen i have to do it manually. Then all my project files are closed (not collapsed as it was before). Its just annoying.
Anyway, the log file from dusk keep telling me that reposnd is 404
Same problem as @nezaboravi
Any clue what might be going on?
@Maidomax i had to create a new project and i copied my working files over and run dusk and got it working.
I just change _APP_URL=http://localhost_ to _APP_URL=http://localhost:8080/myproject_ in .evn file and it's work fine all. I dont know why!!!
@bravohex Definately does not work for me. It's still trying to test http://localhost
@nezaboravi I figured it out. In config\app.php you should set url to env('APP_URL', 'http://localhost').
The environment variable was not being used. The migration docs are incomplete.
Just in case anyone has a similar problem. In my case is because I had to install Google Chrome on Laravel Homestead. More details here: #50
Wouldn't it be alright if we could specify the URL as a command option? (i.e. php artisan dusk --url=<your-url>)
If anyone is still having issues, try clearing the config cache:
php artisan config:cache
Most helpful comment
If anyone is still having issues, try clearing the config cache: