0

I'm trying to take a screenshot of an Angular page using protractor and mocha. We've been using protractor-screenshot-utils as a dependency and have this on the conf.js file to override the browser.takeScreenshot();

onPrepare: function() {
    global.screenShotUtils = new screenShotUtils({
      browserInstance : browser,
      setAsDefaultScreenshotMethod : true 
    });
},

Unfortunately it doesn't totally override it and I'm not able to take a full page screenshot of an angular page (it's completely working on non-angular page). The screenshot that the test is getting, is what the browser can show, not including the rest of the page which boils down to my question...

Is there any other workaround to take a whole page screenshot of an Angular page using protractor + mocha?

ohlori
  • 312
  • 1
  • 8
  • 22

2 Answers2

0

It might be your navigator, if your using chrome that has a problem. https://bugs.chromium.org/p/chromium/issues/detail?id=45209

You might use an hack to fix it

browser.driver.manage().window().setSize(320, 2000);

I recommend you to have a look here, it might help : How to take screenshot of entire page in Protractor?

crg
  • 4,284
  • 2
  • 29
  • 57
0

I had faced a similar issue earlier. I had used a custom method in C# to scroll and capture the screenshot and then stitch them. I know this could be cumbersome but does the job when it's required. The logic can work something on these lines -

  1. You note the height, width of the web page
  2. You check the condition if the bottom of the page has reached
  3. You take a screenshot and save it
  4. You scroll down by the height value
  5. Repeat STEP NO 2

Also, there are some 3rd party libraries you can use to resolve this.

Though I do not have the script readily available with me you can review these helpful resources - protractor.screenshot.reporter.js (from this StackOverflow answer), protractor-screenshot-utils, takeFullPageScreenShot method

Xtraterrestrial
  • 651
  • 1
  • 6
  • 12
  • As listed on the description, I was using protractor-screenshot-utils already. Unfortunately it does not work on Angular 8. – ohlori May 12 '21 at 13:57
  • Hey @MielYan - Can you confirm if you have tried this on - [1] Chrome with the latest version, [2] Chrome lower version (say v75), [3] Firefox? It is a possibility that the issue could be specific to a Browser + Angular 8 combination. – Xtraterrestrial May 13 '21 at 15:12