testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

takeScreenshot with fullpage: true is not working as expected

Open mihaisorintoma opened this issue 4 years ago • 7 comments

What is your Test Scenario?

I want to create a screenshot of the entire page, thus I use .takeScreenshot({fullPage: true})

What is the Current behavior?

The screenshot generated has a scrollbar. The footer is not entirely visible.

What is the Expected behavior?

The screenshot generated contains the whole page, without any scroll.

What is your web application and your TestCafe test code?

https://advancedinstaller.com/blog/page-1.html

import {Selector} from 'testcafe'

fixture `test`
  .page(`https://advancedinstaller.com/blog/page-1.html`)

    test(`test screenshot of blog page}`, async t => {
      await t
        .resizeWindow(768,800)
        .click(Selector('#cookies button'))
        .takeScreenshot({fullPage: true});
    });

Steps to Reproduce:

  1. Run the test code above using "testcafe chrome:headless"

Your Environment details:

  • testcafe version: 1.11.0
  • node.js version: v10.15.3
  • command-line arguments: testcafe chrome:headless
  • browser name and version: Chrome 88.0.4324.150
  • platform and version: Windows 10 x64 20H2
  • other: None

mihaisorintoma avatar Feb 16 '21 16:02 mihaisorintoma

Thank you for sharing the example. I reproduced the issue. We need time to research it.

AlexKamaev avatar Feb 17 '21 08:02 AlexKamaev

Hi @AlexKamaev I'd like to work on this if this is not fixed. Would also appreciate if you can provide some insights on what might actually have caused this issue (since this is my first contribution in TestCafe).

sharath2106 avatar Mar 22 '21 17:03 sharath2106

We'd appreciate it if you contribute to the development of the application. It looks like you should debug screenshot cropping in the Capturer module. Try to do this.

viktoria2506 avatar Mar 24 '21 09:03 viktoria2506

Okay @viktoria2506!

sharath2106 avatar Mar 24 '21 09:03 sharath2106

I believe I am experiencing this issue as well. Has it been fixed? Seems like the PR is still open and not yet merged.

avimredis avatar Jul 18 '22 12:07 avimredis

Hello, @avimredis!

This issue is caused by the different behavior between the Chrome and Chrome:headless browsers. We are currently working on this issue and will update this thread once we have any news.

Artem-Babich avatar Jul 19 '22 08:07 Artem-Babich

Hello, @avimredis!

This issue is caused by the different behavior between the Chrome and Chrome:headless browsers. We are currently working on this issue and will update this thread once we have any news.

@Artem-Babich Thanks for the quick reply!

avimredis avatar Jul 19 '22 09:07 avimredis

I am experiencing this as well. Screenshots were full page in the past, but now are cropped. This does occur on Chrome as well as headless Chrome and headless Firefox.

uuRae avatar Oct 26 '22 17:10 uuRae

@uuRae the workaround I found is that if you know about a flaky or failing test and you need to see the full page, you can place this right before the failing step and it will take a full screen

await t.takeScreenshot({ path: DESCRIPTIVE-NAME.png, fullPage: true, })

I think it's specifically a bug with the screenshot on fail, so this works

avimredis avatar Oct 26 '22 19:10 avimredis

Release v2.1.0-rc.1 addresses this.

github-actions[bot] avatar Nov 03 '22 07:11 github-actions[bot]