Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: chrome driver makes screenshot just of visible part of page

I need to do screenshot of full page using chrome driver, but it makes it partly.

File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

The screenshot looks as visible rectangle with correct information and big black area below.

like image 508
user1180701 Avatar asked Jul 26 '13 15:07

user1180701


2 Answers

This is a known bug: https://code.google.com/p/chromedriver/issues/detail?id=294 (Only for Chrome driver, firefox driver works fine)

like image 109
Nathan Merrill Avatar answered Oct 21 '22 09:10

Nathan Merrill


Might worth trying to use this library:

https://www.assertthat.com/posts/selenium_shutterbug_make_custom_screenshots_with_selenium_webdriver

To make a full page screenshot:

Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS).save();

(it uses scroll-and-stitch method)

Sources on github https://github.com/assertthat/selenium-shutterbug

Provides ability to make full page screenshot in Chrome and some other extended features, tested on Windows and OS X.

Successfully using on my current project.

like image 25
Glib Briia Avatar answered Oct 21 '22 08:10

Glib Briia