Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Chrome Mink Driver Laravel Package

dmore/chrome-mink-driver

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require dmore/chrome-mink-driver
    

    Ensure Chrome is installed and accessible via $PATH.

  2. Basic Configuration In config/mink.php, add the Chrome driver:

    'drivers' => [
        'chrome' => [
            'class' => \DMore\ChromeMinkDriver\ChromeDriver::class,
            'args' => [
                'chromeOptions' => [
                    'args' => ['--headless', '--disable-gpu'],
                ],
            ],
        ],
    ],
    
  3. First Use Case Use the driver in a Laravel test:

    use DMore\ChromeMinkDriver\ChromeDriver;
    
    public function testChromeDriver()
    {
        $driver = new ChromeDriver();
        $session = $driver->start();
        $session->visit('https://laravel.com');
        $this->assertEquals('Laravel', $session->getTitle());
        $session->quit();
    }
    

Implementation Patterns

Workflows

  1. Headless vs. Headful Testing Toggle Chrome options dynamically:

    $driver->setChromeOptions(['args' => ['--no-sandbox', '--disable-dev-shm-usage']]);
    
  2. Session Management Reuse sessions for multi-step tests:

    $session = $driver->start();
    $session->visit('/login');
    // ... perform actions ...
    $session->quit(); // Explicit cleanup
    
  3. Integration with Laravel Testing Extend Laravel’s BrowserKit or use Mink directly:

    use Facebook\WebDriver\Remote\RemoteWebDriver;
    use DMore\ChromeMinkDriver\ChromeDriver;
    
    public function testWithMink()
    {
        $driver = new ChromeDriver();
        $session = $driver->start();
        $this->assertEquals('Home', $session->getPage()->find('css', 'h1')->getText());
    }
    

Tips for Daily Use

  • Page Object Pattern: Encapsulate Chrome interactions in reusable classes.
  • Debugging: Use Chrome’s --remote-debugging-port for manual inspection.
  • Parallel Testing: Leverage Chrome’s multi-tab support for concurrent tests.

Gotchas and Tips

Pitfalls

  1. Chrome Version Mismatch

    • Ensure the installed Chrome version matches the driver’s supported range.
    • Debug with: chrome --version and check driver compatibility.
  2. Headless Mode Quirks

    • Some CSS/JS may render differently in headless mode. Test critical paths manually.
    • Add --disable-gpu to avoid sandbox errors in CI.
  3. Session Leaks

    • Always call $session->quit() to free resources, especially in CI.
    • Use try-finally blocks for cleanup:
      try {
          $session->visit('/admin');
      } finally {
          $session->quit();
      }
      

Debugging Tips

  • Logs: Enable ChromeDriver logs via:
    $driver->setChromeOptions(['logPath' => storage_path('logs/chromedriver.log')]);
    
  • Network Inspection: Use --remote-debugging-port=9222 and access http://localhost:9222.
  • Common Errors:
    • Connection refused: Chrome not running or port blocked.
    • Element not found: Use explicit waits ($session->wait()).

Extension Points

  1. Custom ChromeOptions Override defaults per test environment:

    $driver->setChromeOptions([
        'args' => ['--window-size=1920,1080'],
        'binary' => '/path/to/custom/chrome',
    ]);
    
  2. Proxy Support Configure for testing behind proxies:

    $driver->setChromeOptions([
        'proxy' => [
            'httpProxy' => 'http://proxy.example.com:8080',
            'sslProxy' => 'http://proxy.example.com:8080',
        ],
    ]);
    
  3. Integration with Laravel Dusk Replace Dusk’s Selenium with ChromeMink for lighter tests:

    // config/dusk.php
    'browser' => 'chrome',
    'browserDriver' => 'chrome',
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel