问题
Can anyone help, I am unable to get Laravel dusk to run the default sample test in my current Laravel 5.6 project on mac high sierra.
Error message
Time: 2.5 minutes, Memory: 14.00MB
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"/Users/keith/Desktop/dusk/vendor/laravel/dusk/bin/chromedriver-mac","args":["--disable-gpu"]}}}
Operation timed out after 30002 milliseconds with 0 bytes received
/Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286 /Users/keith/Desktop/dusk/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 /Users/keith/Desktop/dusk/tests/DuskTestCase.php:40 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:189 /Users/keith/Desktop/dusk/vendor/laravel/framework/src/Illuminate/Support/helpers.php:770 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:190 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:92 /Users/keith/Desktop/dusk/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64 /Users/keith/Desktop/dusk/tests/Browser/ExampleTest.php:21
I have already done the following :
- added the following to app\Providers\AppServiceProvider.php
use Laravel\Dusk\DuskServiceProvider;
...
public function register()
{
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}
- ran 'php artisan dusk:install' in terminal
- set App_URL in .env to http://localhost:8000
- specified the location of chromedriver in DuskTestCase
- start 'php artisan serve' before running 'php artisan dusk'
Repository : https://github.com/KKOA/dusk
回答1:
try this while you instantiate your browser.. the most important is $driver = retry(5, function () use ($capabilities) {
return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);
Below is how i instantiate my browser
$options = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless', '--no-sandbox']);
$capabilities = DesiredCapabilities::chrome()
->setCapability(ChromeOptions::CAPABILITY, $options)
->setPlatform('Linux');
$driver = retry(5, function () use ($capabilities) {
return RemoteWebDriver::create('http://localhost:9515', $capabilities, 60000, 60000);
}, 50);
$browser = new Browser($this->driver, new ElementResolver($driver, ''));
来源:https://stackoverflow.com/questions/49837939/laravel-dusk-chrome-driver-timeout