Testcafe: Screenshot Error on some Browsers - Unable to locate the page area in the browser window screenshot

Created on 21 May 2018  路  6Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

When I upgrade to the latest TestCafe version (0.20.0) and I run tests with screenshots I get the following error in Chrome and Edge but not in Firefox.

Was unable to take a screenshot due to an error.

Unable to locate the page area in the browser window screenshot at <screenshot path>, because the page area mark with ID <ID number> is not found in the screenshot.

This was not an issue with these three browsers in 0.19.2.

It is odd that even though the error message states Was unable to take a screenshot due to an error. the screenshots are still in the screenshots folder.

What is the expected behavior?

I'm expecting the behavior to mimic Firefox with no errors.

How would you reproduce the current behavior (if this is a bug)?

  1. Download this repo
  2. npm install
  3. Run with the specified browsers

    • npm run test-chrome

    • npm run test-edge

    • npm run test-firefox

Provide the test code and the tested page URL (if applicable)

Tested page URL: www.github.com and www.google.com

Test code
see this repo

Specify your

  • operating system: Windows 10.0.0
  • testcafe version: 0.20.0
  • node.js version: node 8.9.3
  • chrome version: 66.0.3359.181
  • firefox version: 57.0.0
  • edge version: 17.17134.0
Need clarification

Most helpful comment

is there any way to suppress these warnings?

All 6 comments

Hi @rquellh! This is not an error, it's warning. Since v0.19.0 we implemented a cross-platform mechanism for removing browser UI controls from taken screenshots and capturing screenshots of specified elements. Before this TestCafe version, only screenshots taken in IE and Chrome didn't have browser UI elements. In v0.20.0 we introduced such warnings to give us debug information when TestCafe can't determine page's or element's area on a screenshot.

If you don't mind that screenshots of Firefox have browser UI like menus and bars, you can just ignore the warnings. But I suggest you to share the exact warning message and the taken screenshot to help me understand what's wrong in the captured image.

is there any way to suppress these warnings?

Unfortunately, there is no way to disable warnings yet.

The original question was answered. So I will close the issue.

Sorry for the delayed response. I have two concerns:

  1. I understand that this is a warning, but it's really odd to an end user to say Was unable to take a screenshot due to an error. , but then have the screenshot taken anyway.

  2. Also, the new warning is rejecting the promise, so before I was able to use the .then method and use the path argument. Now due to the warning the promise is being rejected.

sample use

t.takescreenshot().then(function(path){//do something with path})

I apologize for a delayed response. I hope that my clarification still can be useful for someone:

  1. It is not an error, it's a warning. Errors force tests to fail, warnings don't. A warning is emitted due to a screenshot contains some parts that can cause some tests (e.g. visual regression tests) to fail. TestCafe doesn't delete incompletes screenshots since they can be very useful for debugging the screenshot cropping code.

  2. This takeScreenshot behavior is not documented. The return value of takeScreenshot must be undefined according to the docs, so the current behavior is a bug-like behavior.

2a. In this case takeScreenshot doesn't reject, it just resolves to null (otherwise a test would be marked as failed). It does this way since the taken screenshot is considered incomplete.

Was this page helpful?
0 / 5 - 0 ratings