-
-
Save dustinleblanc/c49b020419e70f70b40353b3d05a9735 to your computer and use it in GitHub Desktop.
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' |
version: '3' | |
services: | |
chromedriver: | |
image: robcherry/docker-chromedriver:latest | |
expose: | |
- "4444" | |
environment: | |
CHROMEDRIVER_WHITELISTED_IPS: "" | |
CHROMEDRIVER_URL_BASE: "/wd/hub" | |
security_opt: | |
- seccomp:unconfined |
<?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() | |
); | |
} |
I get following error with this:
Facebook\WebDriver\Exception\InvalidSessionIdException: invalid session id
Just for the record: I've found a solution for this, just have to add volume to the container:
volumes:
- /dev/shm:/dev/shm
my docker-compose.yml looks like:
version: '3'
services:
chromedriver:
image: robcherry/docker-chromedriver:latest
volumes:
- /dev/shm:/dev/shm
expose:
- "4444"
environment:
CHROMEDRIVER_WHITELISTED_IPS: ""
CHROMEDRIVER_URL_BASE: "/wd/hub"
security_opt:
- seccomp:unconfined
@dustinleblanc is this still your current Dusk Testing setup for Lando?
Because after much fiddling I keep getting the error: Could not resolve host: chromedriver
This is definitely out of date, but the general concepts should still work, these days I'd use a compose service rather than including a docker-compose file, and I might use the selenium container instead of the robcherry/chromedriver one. My work over the past couple of years just hasn't included much browser testing. I could probably figure out an updated version of this with a bit of work though. If I have time I might do just that.
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!
Inspired by @dustinleblanc's config, see an updated solution here for making the chromedriver and laravel dusk work within Lando.
I get following error with this:
Facebook\WebDriver\Exception\InvalidSessionIdException: invalid session id