How to screenshot full page? This issue did't help me
https://github.com/laravel/dusk/issues/279
I am having same issue.
$response = $browser->visit( url for page with scroll on Y-axis);
$response->resize(1100, 2500)->driver->takeScreenshot($path);
it will only take screen shot of browser visible area on screen, even if you make width and height dynamic using following
$element = $response->element('body');
$element_width = $element->getSize()->getWidth();
$element_height = $element->getSize()->getHeight();
I added this method to DuskTestCase
```
protected function captureFailuresFor($browsers)
{
$browsers->each(function (Browser $browser, $key) {
$body = $browser->driver->findElement(WebDriverBy::tagName('body'));
if (!empty($body)) {
$currentSize = $body->getSize();
$size = new WebDriverDimension($currentSize->getWidth(), $currentSize->getHeight());
$browser->driver->manage()->window()->setSize($size);
}
$browser->screenshot('failure-'.$this->getName().'-'.$key);
});
}
I'm having the same issue, when a test fails I only get a cropped screenshot. Overriding the captureFailuresFor() method solves the problem. But why this isn't working properly by default? Could it be something in my environment?
I'm using Laravel 5.5 on Ubuntu.
To the answer of @xakzona remember to add this to the top of the file:
use Laravel\Dusk\Browser;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverDimension;
Most helpful comment
I added this method to DuskTestCase
```
protected function captureFailuresFor($browsers)
{
$browsers->each(function (Browser $browser, $key) {
$body = $browser->driver->findElement(WebDriverBy::tagName('body'));
if (!empty($body)) {
$currentSize = $body->getSize();
$size = new WebDriverDimension($currentSize->getWidth(), $currentSize->getHeight());
$browser->driver->manage()->window()->setSize($size);
}
$browser->screenshot('failure-'.$this->getName().'-'.$key);
});
}