testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Scrolling to the top of page occurs before taking screenshot by takeElementScreenshot

Open DmitryKalbeka opened this issue 4 years ago • 3 comments
trafficstars

What is your Test Scenario?

To take a screenshot of an element

What is the Current behavior?

The incorrect page area screenshot is taken by takeElementScreenshot due to scrolling to the top of the page

What is the Expected behavior?

The element screenshot is taken

import { Selector } from 'testcafe'

fixture`Tmp`.page`https://www.w3schools.com/js/default.asp`

test(`Tmp`, async (t) => {
  const label = Selector('h2').withExactText('Learning Speed')
  await t.hover(label)
  await t.takeElementScreenshot(label, 'element.png')
})  
Your complete configuration file (if any):
{
  "src": ["src/specs/**/*.ts"],
  "browsers": ["browserstack:chrome"],
  "tsConfigPath": "./tsconfig.json",
  "screenshots": {
    "path": "./screenshots/",
    "pathPattern": "${DATE}_${TIME}/${TEST}/${USERAGENT}/${FILE_INDEX}.png",
    "takeOnFails": false,
    "fullPage": true
  },
  "debugOnFail": false,
  "concurrency": 1,
  "pageLoadTimeout": 30000,
  "selectorTimeout": 10000,
  "assertionTimeout": 30000,
  "reporter": [
    {
      "name": "spec"
    },
    {
      "name": "xunit",
      "output": "reports/test-results/results.xml"
    }
  ]
}
Actual result: ![image](https://user-images.githubusercontent.com/48528215/128344671-00888974-7bf0-4249-91e2-cb113cf6b189.png)
Expected result: ![image](https://user-images.githubusercontent.com/48528215/128344537-159955ca-2e67-4ea7-9bf2-3e2d575866c4.png)

Note:

It works correctly on browserstack

Your Environment details:

  • testcafe version: 1.9.3, 1.15.1
  • node.js version: 14.15.0
  • command-line arguments: dotenv -- testcafe chrome src/specs/tmp.ts
  • browser name and version: Chrome 92
  • platform and version: Windows 10

DmitryKalbeka avatar Aug 05 '21 12:08 DmitryKalbeka

Hi,

Thank you for your input. We have reproduced the problem and need some time to investigate it, please stay tuned.

AlexanderMoiseev avatar Aug 06 '21 08:08 AlexanderMoiseev

I have noticed that reason is screenshots.fullPage:true of .testcaferc.json config. Screenshot works correctly on local browser without this, and sometimes the entire page is screenshotted on BrowserStack with if this parameter is defined

DmitryKalbeka avatar Aug 09 '21 14:08 DmitryKalbeka

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] avatar Aug 10 '22 02:08 github-actions[bot]

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

github-actions[bot] avatar Aug 20 '22 02:08 github-actions[bot]