creasi/dusk-browserstack

Additional BrowserSstack Supports for Laravel Dusk

v0.3.7 2024-10-06 06:06 UTC

README

Version License

Additional BrowserStack Local Supports for Laravel Dusk

Installation

Use Composer

$ composer require creasi/dusk-browserstack --dev

Usage

  1. Add WithBrowserStack to your existing DuskTestCase, like so

    use Laravel\Dusk\TestCase as BaseTestCase;
    use Creasi\DuskBrowserStack\WithBrowserStack;
    
    abstract class DuskTestCase extends BaseTestCase
    {
        use CreatesApplication;
        use WithBrowserStack;
    
        // ...
    }
  2. Update prepare method

    use Creasi\DuskBrowserStack\BrowserStack;
    
    public static function prepare()
    {
        if (BrowserStack::hasAccessKey()) {
            static::startBrowserStackLocal();
            return;
        }
    
        if (! static::runningInSail()) {
            static::startChromeDriver();
        }
    }
  3. Update driver method

    use Creasi\DuskBrowserStack\BrowserStack;
    
    protected function driver()
    {
        // ...
    
        $capabilities = DesiredCapabilities::chrome()
            ->setCapability(ChromeOptions::CAPABILITY, $options);
        
        return RemoteWebDriver::create(
            BrowserStack::getDriverURL(),
            $this->withBrowserStackCapabilities($capabilities)
        );
    }
  4. Last one, don't forget to update your .env file

    BROWSERSTACK_USERNAME='<your-browserstack-username>'
    BROWSERSTACK_ACCESS_KEY='<your-browserstack-access-key>'

License

This library is open-sourced software licensed under MIT license.