Created
March 18, 2018 17:29
-
-
Save dustinleblanc/c49b020419e70f70b40353b3d05a9735 to your computer and use it in GitHub Desktop.
Setting up Laravel Dusk with ChromeDriver and Lando
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cool-app | |
recipe: laravel | |
compose: | |
- docker-compose.yml | |
config: | |
php: '7.1' | |
via: nginx | |
webroot: public | |
database: postgres | |
cache: redis | |
services: | |
appserver: | |
composer: | |
phpunit/phpunit: '*' | |
testdb: | |
type: postgres | |
creds: | |
user: laravel | |
password: laravel | |
database: laravel | |
node: | |
type: node:latest | |
tooling: | |
phpunit: | |
service: appserver | |
redis-cli: | |
service: cache | |
yarn: | |
service: node | |
node: | |
service: node | |
npm: | |
service: node | |
robo: | |
service: appserver | |
cmd: 'vendor/bin/robo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
chromedriver: | |
image: robcherry/docker-chromedriver:latest | |
expose: | |
- "4444" | |
environment: | |
CHROMEDRIVER_WHITELISTED_IPS: "" | |
CHROMEDRIVER_URL_BASE: "/wd/hub" | |
security_opt: | |
- seccomp:unconfined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests; | |
use Laravel\Dusk\TestCase 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://chromedriver:4444/wd/hub', DesiredCapabilities::chrome() | |
); | |
} |
Inspired by @dustinleblanc's config, see an updated solution here for making the chromedriver and laravel dusk work within Lando.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well if you are willing to create a small guide for it as you mentioned somewhere it would be great! Because, having spend half a day to get this working I gave up for now.
I have no clue why the appserver cannot reach the chromedriver while they are in the same docker network. I keep getting that
Could not resolve host: chromedriver
error.But thanks for your examples so far!