Full page screenshot in Chrome with Selenium WebDriver
One line java solution for taking full page screenshot in Chrome using WebDriver and selenium-shutterbug
One can come across two definitions of ‘screenshot’ while using WebDriver.
First is that screenshot is an image of the entire DOM of the loaded page, which is exactly what Firefox and IE drivers are doing.
Second one is used in W3C WebDriver specification where a screenshot is defined as an image of the top-level browsing context’s viewport.
ChromeDriver is following the latter definition and there is an open issue raised in this regard: chromium - 294
It really becomes a matter of dispute when discussing which one of the definitions above should be adhered to.
Nevertheless there is a necessity to get the full page screenshot while running tests. To accomplish this I would recommend to use the following line:
which will make the full page screenshot in Chrome and any other browser of your choice.
For installation and further usage info please refer to selenium-shutterbug
Update 16/07/2018: The issue was fixed in Chrome 64, Page.captureScreenshot is now available in Chrome DevTools to capture full page snapshot.
This is now encapsulated in shutterbug v. 0.8 and can be used as follows:
Shutterbug.shootPage(driver, ScrollStrategy.WHOLE_PAGE_CHROME, true).save();
If you using Chrome v. 64 or older scrolling approach still can be used:
Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS, 500, true).save();