testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Screenshots do not get taken for all failure conditions

Open switch201 opened this issue 7 years ago • 5 comments

What is your Test Scenario?

I am throwing a custom exception in typescript from one of my cucumber steps. I am using the test runner API and I have everything set up to take screen shots on failure. this works when throwing an assertion error, but other error types don't appear to cause the screenshot to be taken.

What is the Current behavior?

A screenshot is not taken in these cases even though the test fails

What is the Expected behavior?

A failure screen should be taken when an exception is thrown from a cucumber step, (while screenshots on failure are enabled)

What is your web application and your TestCafe test code?

I am throwing the exception like so:

throw new Error("Wait Time Out Exception. An element you were waiting for did not appears after " + timeout.toString() + " seconds.")

Your website URL (or attach your complete example): N/A

Your complete test code (or attach your test files):
Create a cucumber st
Your complete configuration file (if any):
TestCafe version 1.6.0
Your complete test report:

Screenshots:

Steps to Reproduce:

  1. Configure the test runner API to allow for screenshots on failure
  2. Create a step that goes to a web page, and then throws a custom exception similar to what is shown above
  3. The screenshot will not be taken for this failure but it should be.

Your Environment details:

  • testcafe version:
  • node.js version:
  • command-line arguments:
  • browser name and version:
  • platform and version:
  • other:

switch201 avatar Nov 12 '19 18:11 switch201

I think the same behavior can occur when testcafe throws an error (for example what it can't find an action element on the screen or something similar). If possible it should take a screen shot in these cases as well.

switch201 avatar Nov 12 '19 18:11 switch201

I've checked the screnario and it works.

Here is the test code:

fixture `New Fixture`
    .page `http://example.com`;

test('New Test', async t => {
    throw new Error('It is a custom error');
});

And here is my terminal command:

testcafe chrome index.ts -s takeOnFails=true

I've got a screenshot as expected. Could you please provide with a more detailed description and test code, which demonstrates the issue?

AlexKamaev avatar Nov 18 '19 11:11 AlexKamaev

In my case I am setting the screenshot option via the test runner API rather than on the command line. here is that code snippet:

    createTestCafe('localhost')
      .then(function (tc: any) {
        testcafe = tc
        myTestCafe = tc
        runner = tc.createRunner()
        let screenshotPath = 'artifacts/screenshots/testcafe'
        if(process.env.SCREENSHOT_PATH){
          screenshotPath = process.env.SCREENSHOT_PATH
        }
        return runner
          .src(stepDefinitionsPath + '/test.js')
          .browsers(getBrowserSettings())
          .reporter('list')
          .screenshots({path: screenshotPath, takeOnFails: process.env.SCREENSHOT == 'true', fullPage: true})
          .run({
            skipJsErrors: true,
            quarantineMode: true,
            selectorTimeout: 10000,
            assertionTimeout: 10000,
            pageLoadTimeout: 10000
            //speed: 0.1
          })
          .catch(function (error: any) {
            console.error('Runner error count was: ', error)
          })
      })
      .then(function (report: any) {
        console.error('Report data was: ', report)
      })

switch201 avatar Nov 26 '19 19:11 switch201

I've created an example with Runner API and it works as expected. Could you please provide a simple example that we can run locally without any additional setup?

miherlosev avatar Nov 27 '19 14:11 miherlosev

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

no-response[bot] avatar Dec 07 '19 14:12 no-response[bot]