-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testcafe is taking screenshot on catched expect Errors #5157
Comments
Also, please note that the screenshot behavior is documented as: |
Thank you for your input. We need additional time to research your case and find the most suitable solution. We will update this issue when we have any news. |
+1 |
I'm unable to provide you with any time frame as any personal estimate may be misleading. Once we get any results, we will update this thread. |
This is super annoying! Makes it hard to find the real screenshots since so many fake (from non failing tests) ones are created. |
I apologize for the inconvenience caused by this bug. I increased the bug level, so we will give it a higher priority when planning the next development sprint. However, if the issue is caused by a failed assertion that checks for element existence, you can use the Selector.exists property instead of suppressing the assertion error. @cattermo, @Shreky could you please share your error suppressing cases as well? For the team: import fs from 'fs';
fixture `Fixture`;
test('Test', async t => {
if(!fs.existsSync('screenshots'))
fs.mkdirSync('screenshots');
try {
await t.expect(false).ok();
}
catch (e) {
}
await t.expect(fs.readdirSync('screenshots').length).eql(0);
}); It is caused by the explicit screenshot capture call, which didn't exist in previous versions: |
I ended up rebuilding the test so no error will be thrown but I don't know if the new solution will be stable. I couldn't get it to wait in the same way. My use case is a button that might be disabled but might also loose the disabled attribute if we wait a little. If it keeps the disabled attribute it should fail unless some other condition is true (which is why we caught the error previously). Now I check for the disabled attribute instead but the hasAttribute will not wait so it's not the same as previously. |
@cattermo |
FYI, this is also an issue when skipjserrors is set to true. If a test passes without any errors, a screenshot still gets generated if there are browser console errors. Additionally, when a test does fail, sometimes it only includes the screenshot taken when a js error occurs, not when the assertion fails. This makes it very difficult to troubleshoot test failures. |
@Makavelic <!DOCTYPE html>
<html>
<head>
</head>
<body>
<button>click me</button>
<script>
document.querySelector('button').addEventListener('click', () => {
throw new Error('error');
});
</script>
</body>
</html> Test code: fixture('screehshots and js errors')
.page `..\\pages\\index.html`;
test('Log in to Paypal', async t => {
await t.click('button');
}); I use the following command to run TestCafe:
This behavior seems correct. If the page has JS error and there is no |
@AlexKamaev
test2.html
test
Note: You'll need to update the paths, I was just using hard coded paths which I removed here. |
@Makavelic I am using the following command to run tests: My TestCafe version is 1.9.4. Could you please specify which command you are using to run tests? Please also specify the browser, OS, and the TestCafe version. |
@AlexKamaev, I'm using a custom runner, here are the relevant parts:
Testcafe: 1.9.4 Screenshots are taken on all of our tests even when they do not fail. This did not occur in earlier versions of testcafe. |
@Makavelic |
I can no longer reproduce using my test pages. It's still consistent when testing my companies actual product though. It happens even when the dev console doesn't show any errors (only warnings). Now that that we improved our logging we're also seeing logs indicating that screenshots are being overwritten (so multiple screenshots are generated during a failed test).
This occurs even though we're using pathPattern: '${TEST}/${DATE}_${TIME}.png'}) and not running tests concurrently. |
Unfortunately, there's not much we can say here without a reproducible example. As for screenshots that are being overwritten, you can try to add the |
Is there a way to get more logging from testcafe to hopefully gather more info that would be useful? For whatever reason, testcafe takes a screenshot after logging into the website its testing. |
There is a guide in our docs, which describes how to debug TestCafe tests: Debug. Manual step-by-step execution should help to identify a particular test action or assertion after which the screenshot is taken. |
Hi folks, The problem occurs because you use an assertion for checking element visibility or existence. If you have some problems getting rid of caught assertion errors, please describe them in separate issues. We will investigate them separately. |
Hi issue is closed but I am { Any help will |
Hi @testcafe-HK , |
What is your Test Scenario?
We sometimes have to catch the error thrown by testcafe.expect, for example when we want to verify a process involving an asynchronous backend task. In that case we try to validate the existance of an element on the page and if not found, catch the Error, wait some time, reload the page and assert again. This works regarding the test result, so at the end if the element is found eventually, even though some of the testcafe.expects did not succeed, the test is green, which is also our expectation.
We have also activated the screenshot-option "takeOnFails". To our surprise, enabling this option leads to screenshots being taken, even if the exception thrown by the testcafe.expect call is catched.
If our approach is not optimal regarding catching the Exception, please guide us to a way that is more appropriate.
What is the Current behavior?
a catched testcafe.expect Exception leads to a screenshot being taken if the option "takeOnFails" is true
What is the Expected behavior?
screenshots are only taken for failed tests
Your Environment details:
The text was updated successfully, but these errors were encountered: