marbobo's avatar
Level 12

laravel dusk full page screenshot

How can I take fullpage screenshot on laravel dusk headless testing? I do something but I only get the visible part.

    /**
     * A Dusk test example.
     *
     * @return void
     */
    public function testAuthenticated()
    {
        $this->browse(function (Browser $browser) {
            $browser->loginAs(1)->visit('/browse')
                ->assertSee('CATEGORIES')
                ->screenshot('authenticated_test_screenshot');
        });
    }

0 likes
4 replies
bugsysha's avatar
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);
        }
        $name = str_replace('\', '_', get_class($this)).'_'.$this->getName(false);

        $browser->screenshot('failure-'.$name.'-'.$key);
    });
}
3 likes
marbobo's avatar
Level 12

thanks gonna try this. i'll accept this if it works

frank.wallen's avatar

It almost did for me. I'm working with a long page and it got most of it, so I'm probably going to make some adjustments.

Please or to participate in this conversation.