Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Drivers/Chrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}


Expand Down
14 changes: 13 additions & 1 deletion src/Dusk.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Dusk
*/
private $browser;

private $dir;

/**
* Create a new instance.
Expand All @@ -28,6 +29,7 @@ public function __construct(DriverInterface $driver = null)
}

$this->browser = new Browser($driver->getDriver());
$this->driver = $driver;
}


Expand Down Expand Up @@ -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;
}
Expand Down