Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take screenshot of entire page in Protractor?

Following Protractor API documentation there should be a way to take screenshot of entire page, not only visible frame. In fact it should be default behaviour.

When takeScreenshot() is called like

browser.takeScreenshot().then(function (png) {
    // writing down image
});

Then in file is saved option 3. from documentation - 'Visible portion of current frame'. How to force webdriver to take full page screenshot?

like image 283
Patzick Avatar asked Jul 14 '15 12:07

Patzick


People also ask

How do I take a screenshot of a whole protractor?

takeScreenshot(). then(function (png) { // writing down image }); Then in file is saved option 3.


2 Answers

This is a hack, but you can set the height of the browser in your onPrepare to be 2000 pixels or some other high value:

browser.driver.manage().window().setSize(320, 2000);
like image 184
Alex W Avatar answered Oct 20 '22 00:10

Alex W


there is a bug on chrome. https://bugs.chromium.org/p/chromium/issues/detail?id=45209 https://bugs.chromium.org/p/chromedriver/issues/detail?id=294
After change browser height(browser.driver.manage().window().setSize(320, 2000);), Firefox will take entire page screenshot, but not Chrome.

like image 45
Abdullah Nurum Avatar answered Oct 20 '22 01:10

Abdullah Nurum