Skip to content

Commit

Permalink
Merge pull request #26 from derekmd/feat/start-maximized-env-var
Browse files Browse the repository at this point in the history
[1.x] Support environment variable `DUSK_START_MAXIMIZED` for Chromedriver
  • Loading branch information
derekmd authored Feb 10, 2023
2 parents ae0747e + 8cea2fa commit 73681b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/Concerns/TogglesHeadlessMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ protected function hasHeadlessDisabled()
return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
isset($_ENV['DUSK_HEADLESS_DISABLED']);
}

/**
* Determine if the browser window should start maximized.
*
* @return bool
*/
protected function shouldStartMaximized()
{
return isset($_SERVER['DUSK_START_MAXIMIZED']) ||
isset($_ENV['DUSK_START_MAXIMIZED']);
}
}
2 changes: 1 addition & 1 deletion stubs/DuskTestCase.stub
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class DuskTestCase extends BaseTestCase
$options = (new ChromeOptions)->addArguments($this->filterHeadlessArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
]));

return RemoteWebDriver::create(
Expand Down
6 changes: 2 additions & 4 deletions stubs/FirefoxDuskTestCase.stub
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ abstract class DuskTestCase extends BaseTestCase
*/
public static function prepare()
{
if (static::runningFirefoxInSail()) {
return;
if (! static::runningFirefoxInSail()) {
static::startFirefoxDriver();
}

static::startFirefoxDriver();
}

/**
Expand Down

0 comments on commit 73681b2

Please sign in to comment.