Browser Testing
Lerd ships a Selenium service preset that runs Chromium inside a container on the same Podman network as nginx and PHP-FPM. This lets browser testing frameworks like Laravel Dusk drive a real browser against your .test sites without installing Chrome or ChromeDriver on your host machine.
Quick start (Laravel Dusk)
1. Install the Selenium preset
lerd service preset selenium
lerd service start seleniumThis starts a selenium/standalone-chromium container with:
- WebDriver on port 4444
- noVNC dashboard on port 7900: open
http://localhost:7900to watch tests run in the browser
The container automatically resolves .test domains to the nginx container so Chromium can load your sites over HTTP and HTTPS.
2. Install Dusk
lerd composer require --dev laravel/dusk
lerd artisan dusk:install3. Run lerd env
lerd envWhen lerd env detects laravel/dusk in composer.json and the Selenium preset is installed, it automatically:
- Adds
DUSK_DRIVER_URL=http://lerd-selenium:4444to.env - Patches
tests/DuskTestCase.phpto skip starting a local ChromeDriver whenDUSK_DRIVER_URLis set - Adds
--ignore-certificate-errorsto Chrome options so Chromium accepts lerd's mkcert certificates
These changes are compatible with Sail and other environments; when DUSK_DRIVER_URL is not set, the default local ChromeDriver behaviour kicks in as usual.
4. Run tests
lerd artisan dusk
lerd artisan dusk --filter=homepageWatching tests
Open the noVNC dashboard at http://localhost:7900 to see the Chromium browser in real time. This is useful for debugging failing tests or understanding what the browser sees.
How it works
The Selenium container joins the lerd Podman network and mounts a hosts file that maps all .test domains to the nginx container's internal IP. When Dusk tells Chromium to visit https://myapp.test, the browser resolves the domain inside the container, connects to nginx over the Podman network, and nginx proxies to PHP-FPM as usual.
Dusk (PHP-FPM) → WebDriver API → Selenium container → Chromium
↓
https://myapp.test
↓
lerd-nginx → PHP-FPMManaging the service
The Selenium preset is a regular lerd custom service:
lerd service start selenium
lerd service stop selenium
lerd service restart selenium
lerd service remove selenium # uninstallOther frameworks
The Selenium preset works with any browser testing framework that supports remote WebDriver, not just Laravel Dusk. For example:
- Symfony Panther: set
PANTHER_EXTERNAL_BASE_URIandPANTHER_CHROME_DRIVER_BINARYor use the remote WebDriver directly - Pest with Dusk plugin: same setup as Laravel Dusk above
- PHPUnit + php-webdriver: connect to
http://lerd-selenium:4444withRemoteWebDriver::create()