Bug
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.
I'm expecting the behavior to mimic Firefox with no errors.
npm installnpm run test-chromenpm run test-edgenpm run test-firefoxTested page URL: www.github.com and www.google.com
Test code
see this repo
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:
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.
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:
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.
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.
Most helpful comment
is there any way to suppress these warnings?