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

screenshots are duplicated when using ScreenShooterExtension and Allure #1002

Closed
asolntsev opened this issue Oct 21, 2019 · 6 comments · Fixed by #1125
Closed

screenshots are duplicated when using ScreenShooterExtension and Allure #1002

asolntsev opened this issue Oct 21, 2019 · 6 comments · Fixed by #1125

Comments

@asolntsev
Copy link
Member

See comment #946 (comment)

The problem

Given a project using

  • com.codeborne.selenide.junit5.ScreenShooterExtension
  • Allure

When a test fails
Then two screeenshots are takes.

Details

  1. ScreenShooterExtension takes a screenshot (and just logs it),
  2. Then ScreenShooterExtension triggers Allure listener (via SelenideLogger.commitStep) which also takes a screenshot.

It would be nice to avoid taking 2 screenshots.

Tell us about your environment

  • Selenide Version: 5.4.1
@asolntsev asolntsev changed the title screenshots are duplicate when using ScreenShooterExtension and Allure screenshots are duplicated when using ScreenShooterExtension and Allure Oct 21, 2019
@SeleniumTestAB
Copy link
Contributor

@asolntsev would it be hard to check if logger with name "allure" is present and make condition from it?

@asolntsev
Copy link
Member Author

@SeleniumTestAB it's technically possible, but it doesn't seem to be a good idea in terms of design. Selenide core code should not depend on any listeners.
I would rather suggest that AllureListener could check if Selenide has already taken a screenshot during current test. Maybe we should even create a superclass for such listeners in Selenide.

@SeleniumTestAB
Copy link
Contributor

SeleniumTestAB commented Oct 22, 2019

@asolntsev indeed it seems that fix should be on allure side rather. As for superclass, doesnt SelenideLogger fulfill such role?

But there is one catch, how does Selenide notify Allure that it took screenshot? At first i though about checking if such image file is in report folder but the name of file would differ because of time. Second idea is by making some kind of flag that is set false on beforeStep and true on afterStep if screenshot was taken.

@dstekanov
Copy link
Member

Hi @asolntsev,
I was not able to reproduce this issue, and when I looked inside ScreenShooterExtension I did not find SelenideLogger.commitStep so seems this issue can be closed.

@asolntsev
Copy link
Member Author

@dstekanov I haven't tried to re-reproduce it yet, but my logic says that

  1. When ScreenShooterExtension works without Allure, it takes screenshot.
  2. When Allure works without ScreenShooterExtension, it also takes screenshot.
  3. When `ScreenShooterExtension and Allure are both enabled, they both must take their screenshots (they don't call each other to ask if there is already screenshot taken).

Am I right?

@dstekanov
Copy link
Member

Now I see and seems it's not a problem with ScreenShooterExtension

ScreenShooterExtension does not take (by default) screenshots for UIAssertionError.
So when such non-UIAssertionError happens, e.g. with org.junit.jupiter.api.Assertions, ScreenShooterExtensiontakes a screenshot but it does not update status in LogEvent and Allure does not take a screenshot and there is no attachment in the report...

When we have UIAssertionError, Selenide takes a screenshot and ScreenShooterExtension does not play a role here(because even without the extension it takes it) and Allure also takes a screenshot. So we really have 2 screenshots (1 in allure-results folder, another in reports folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants