diff --git a/src/Drivers/Chrome.php b/src/Drivers/Chrome.php index 369b81c..54e3fc6 100644 --- a/src/Drivers/Chrome.php +++ b/src/Drivers/Chrome.php @@ -5,6 +5,8 @@ use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; use Laravel\Dusk\SupportsChrome; +use Facebook\WebDriver\Chrome\ChromeOptions; +use Facebook\WebDriver\Remote\WebDriverCapabilityType; class Chrome implements DriverInterface { @@ -27,7 +29,18 @@ public function __construct() */ public function getDriver() { - return RemoteWebDriver::create("http://localhost:9515", DesiredCapabilities::chrome()); + $options = (new ChromeOptions)->addArguments([ + '--headless', + '--disable-gpu', + '--no-sandbox', + '--ignore-certificate-errors', + 'window-size=1280,960', + ]); + $cap = DesiredCapabilities::chrome(); + $cap->setCapability(ChromeOptions::CAPABILITY, $options); + $cap->setCapability(WebDriverCapabilityType::ACCEPT_SSL_CERTS, true); + $cap->setCapability('acceptInsecureCerts', true); + return RemoteWebDriver::create("http://localhost:9515", $cap); } diff --git a/src/Dusk.php b/src/Dusk.php index 95690d8..22b3424 100644 --- a/src/Dusk.php +++ b/src/Dusk.php @@ -15,6 +15,7 @@ class Dusk */ private $browser; + private $dir; /** * Create a new instance. @@ -28,6 +29,7 @@ public function __construct(DriverInterface $driver = null) } $this->browser = new Browser($driver->getDriver()); + $this->driver = $driver; } @@ -88,7 +90,17 @@ public function getDriver() */ public function screenshot($filename) { - $this->getDriver()->takeScreenshot("/tmp/{$filename}.png"); + $this->getDriver()->takeScreenshot($this->dir . "/{$filename}.png"); + + return $this; + } + + public function screenshotDir($dir = null) + { + if( empty($dir) ){ + return $this->dir; + } + $this->dir = $dir; return $this; }