Skip to content
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

[🐛 Bug]: Cucumber - Screenshot not attached in Allure report in failed step #8323

Closed
3 tasks done
anupamck opened this issue May 10, 2022 · 8 comments
Closed
3 tasks done
Labels
Bug 🐛 Docs 📖 Needs Triaging ⏳ No one has looked into the issue yet

Comments

@anupamck
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

7.19.17

Node.js Version

14.17.6

Mode

Standalone Mode

Which capabilities are you using?

Cucumber

What happened?

Despite clearly including the command for capturing screenshot in case of failure in the Afterstep hook, no screenshot is captured and attached in the Allure report.
afterStep: function (step, scenario, result, context) { // browser.takeScreenshot(); if(!result.passed) { browser.takeScreenshot(); console.log("A test has failed!"); } },

I've also ensured that the disableWebdriverScreenshotsReporting flag is set to false.

Further, the log message directly below the screenshot works. Therefore, the hook is executed. I also notice that if I take a screenshot before the if(!result.passed) condition, screenshots are attached in every step in the Allure report, which is the expected behaviour.

What is your expected behavior?

Screenshots are attached with the failed step in the Allure report.

How to reproduce the bug.

https://github.com/anupamck/wdio-allure-screenshot-bug

It is just the standard example repo with cucumber + page objects and one additional test.

Relevant log output

-

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues
@anupamck anupamck added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels May 10, 2022
@praveendvd
Copy link
Contributor

@anupamck you should use async await for hooks too , could you try that :

afterStep: async function (step, scenario, result, context) { // browser.takeScreenshot(); i

f(!result.passed) { 
await browser.takeScreenshot(); 

console.log("A test has failed!"); } },

@praveendvd
Copy link
Contributor

praveendvd commented May 17, 2022

#7940 (comment)

@praveendvd
Copy link
Contributor

Please leave a comment if its still needs to reopened

@anupamck
Copy link
Contributor Author

@praveendvd - Thank you! Making it async resolved the problem.

If that is the case, does it not make sense to update this in the documented example too? Under documentation?

@christian-bromann
Copy link
Member

If that is the case, does it not make sense to update this in the documented example too? Under documentation?

Can you point to where in the docs this is wrong?

@anupamck
Copy link
Contributor Author

https://webdriver.io/docs/allure-reporter/

afterStep: function (step, scenario, { error, duration, passed }, context) {
  if (error) {
    browser.takeScreenshot();
  }
}

It isn't wrong, strictly speaking, since the feature works in most cases without async await. But if this issue isn't a bug, I think the document ought to also mention this.

@praveendvd
Copy link
Contributor

praveendvd commented May 17, 2022

@anupamck @christian-bromann its better to update that as we have same issue reopened many times, thanks for pointing it out .

Previously we used to support webdriverio sync mode. Now its not there so will update that documentation

@christian-bromann
Copy link
Member

Thanks both @praveendvd and @anupamck 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Docs 📖 Needs Triaging ⏳ No one has looked into the issue yet
Projects
None yet
Development

No branches or pull requests

3 participants