instaclick/php-webdriver
PHP client for Selenium WebDriver, enabling browser automation and end-to-end testing from PHP. Control Chrome/Firefox/RemoteWebDriver, manage sessions, elements, waits, and actions, with support for Selenium Grid and popular testing frameworks.
instaclick/php-webdriver package is a thin WebDriver client for PHP, enabling interaction with Selenium 2/3 and W3C-compliant browsers (Chrome, Firefox, Edge, etc.). It is ideal for:
Laravel\Dusk (which is deprecated) or augment existing tests with WebDriver for cross-browser validation.php artisan test:browser).php artisan queue:work).WebDriver namespace; ensure no clashes with Laravel’s Illuminate\Support\Facades\WebDriver (if any).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| PHP Version Mismatch | High | Pin PHP version in composer.json (e.g., ^8.1). |
| Selenium Server Dependency | High | Use Docker (e.g., selenium/standalone-chrome) for consistency. |
| Flaky Tests | Medium | Implement retry logic (e.g., retry package). |
| Performance Overhead | Medium | Cache WebDriver instances; use headless mode. |
| Lack of Laravel-Specific Features | Low | Build a facade/service layer for Laravel integration. |
pest --parallel or phpunit --parallel?logs/?facebook/webdriver).selenium/standalone-chrome:latest).pest or phpunit.laravel-queue for async browser tasks.instaclick/php-webdriver.| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | Works, but PHP 8.x may require composer config allow-plugins for polyfills. |
| Dusk | Not directly compatible; treat as a replacement. |
| Pest/PHPUnit | Integrates via custom test classes (e.g., WebDriverTestCase). |
| Docker | Recommended for Selenium Server (avoids host OS dependencies). |
| CI/CD | Needs Selenium Server in CI (e.g., GitHub Actions with Dockerized Selenium). |
webdriver.io or selenium-server in CI/CD.config/webdriver.php).instaclick/php-webdriver.use WebDriver\WebDriver;
use WebDriver\WebDriverExpectedCondition;
public function test_login() {
$driver = new WebDriver('http://selenium:4444/wd/hub');
$driver->get('https://laravel.test/login');
$driver->findElement(WebDriverBy::name('email'))->sendKeys('user@example.com');
// ...
}
docker-compose up selenium).pest --parallel --servers=4).instaclick/php-webdriver to a specific version (avoid auto-updates).app/Services/WebDriverService) to abstract WebDriver logic.storage/logs/ (e.g., via monolog handler).WebDriverExpectedCondition).php-webdriver) is feasible.laravel-queue (e.g., Redis).pest --parallel with dedicated Selenium containers per job.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Selenium Server Crash | Tests hang/fail | Health checks; retry logic. |
| Browser Timeouts | Flaky |
How can I help you explore Laravel packages today?