codeception/module-webdriver
WebDriver module for Codeception that drives real browsers (via Selenium/ChromeDriver/etc.) for end-to-end acceptance testing. Provides browser control, navigation, form interactions, assertions, waits, and screenshots for UI automation.
Start by installing the module via Composer: composer require --dev codeception/module-webdriver. Then enable it in your acceptance.suite.yml (or appropriate suite config), specifying the WebDriver connection (e.g., using Selenium, ChromeDriver, or BrowserStack). Configure the url and browser (e.g., chrome, firefox) under the module settings. Your first test can be a simple navigation and assertion: $I->amOnPage('/'); $I->see('Welcome');. Check the Codeception WebDriver docs for full configuration examples.
Use WebDriver in acceptance tests to simulate real user interactions—clicking buttons, filling forms, handling sessions, or testing JavaScript-heavy SPAs. Leverage helper methods like $I->waitForElement(), $I->switchToIFrame(), and $I->wait() for dynamic content. Integrate with CI/CD by headlessly launching browsers (e.g., via chromeOptions: ['args' => ['--headless']]). Chain actions for complex workflows:
$I->click('.login-btn'); $I->fillField('email', 'user@example.com'); $I->submitForm('#login-form');.
Combine with Db and REST modules to validate full-stack behavior (e.g., test UI → DB → API integration). Use waitForText() and waitUntil for reliable async assertions.
⚠️ Ensure the WebDriver server (e.g., Selenium, ChromeDriver) is running before tests start—common failure point. Set restart: false in config only if manually managing browser state; otherwise, tests may retain sessions across cases. Beware of race conditions: avoid sleep(); use explicit waits (waitForElementVisible) instead. The amOnPage() method resets the browser context; use amOnUrl() for absolute URLs without base URL trimming. For CI environments, use Docker images (e.g., selenium/standalone-chrome) and link via host/port config. To debug, set debug option to 'true'—screenshots and logs will be saved on failure. If switching frames/windows, call $I->switchToWindow() before assertions, or they’ll target the wrong context.
How can I help you explore Laravel packages today?