Screenshots not always attaching to report
See original GitHub issueI’m submitting a …
- bug report
- feature request
- support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
Using allure-cucumber-jvm-3 with screenshots after each step and getting every so often so screenshots attached (suspect a race-condition issue). To get screenshots after each step, using custom class:
public class AllureScreenshotPublisher implements Formatter {
private final AllureLifecycle allureLifecycle;
public AllureScreenshotPublisher() {
this.allureLifecycle = Allure.getLifecycle();
}
@Override
public void setEventPublisher(EventPublisher publisher) {
publisher.registerHandlerFor(TestStepFinished.class, this::handleTestStepFinished);
}
private void handleTestStepFinished(final TestStepFinished event) {
byte[] screenShot = ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES);
allureLifecycle.addAttachment(LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MMM-yy_hh:mm:ss")), "image/png", "png", screenShot);
}
}
and then define this as a plugin for each runner:
@CucumberOptions(
glue = {"*.stepdefs"},
features = {"target/parallel/features/[CUCABLE:FEATURE].feature"},
plugin = {"*.allure.AllureScreenshotPublisher",
"io.qameta.allure.cucumber3jvm.AllureCucumber3Jvm"}
)
public class [CUCABLE:RUNNER] extends AbstractTestNGCucumberTests {
}
Any ideas why this fails about 5-10% of the time?
Using: <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-cucumber3-jvm</artifactId> <version>2.7.0</version> </dependency>
and Selenium 3.141.59 (if it helps 😃 )
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (21 by maintainers)
Top Results From Across the Web
Attaching files and screenshots to issues | Jira Software Data ...
You can attach files and screenshots if your Jira admin has enabled file attachments. You need the Create attachments permission in the ...
Read more >Screenshots not attached to Extent Reports C#, DotNet CORE ...
I am trying to add screenshots to my extent reports.My Html reports are created fine but for some reason i am not able...
Read more >Attach screenshot/Base64 format on test failure to emailable ...
This video will explain how to attach screenshot to extent html report on test failure.Also learn how to attach emailable extent report by ......
Read more >Attaching files and Screenshots to issues in JIRA - YouTube
FREE Training's at https://training.rcvacademy.com SUBSCRIBE to CHANNEL: https://bit.ly/38hDawwIn this Jira tutorial we will learn how to ...
Read more >P6 - Attach screenshots to the extent reports - YouTube
In this video, I have explained about " Attach screenshots to the extent reports ".=======================================▶️ Next Video ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey - I have released the framework as an open source project that we use internally. We fixed this issue by changing the stage at which the screenshots were pushed to be at the “afterStepUpdate” method.
The project is here: (documentation need improving!) https://gitlab.developers.cam.ac.uk/jsa34/selenium-java-framework
Hope this helps!
Aha - so, now I am using:
It appears to be fine on a single test, but when I ran the suite in parallel (25 threads) soon after starting, all 25 threads start logging:
04 Jan 2019 14:53:51,330 ERROR [TestNG-test=Surefire test-15] AllureLifecycle:563 - Could not add attachment: no test is running
Once these tests on the threads clear and the next test starts, it appears to no longer be a problem, but those 25 tests that were on the threads at the time that it outed that to the logs had no screenshots attached. Not sure why this is happening? Not enough memory for JVM? Seems odd it affects ALL threads for the duration of the test until a new one is picked up and shortly after the threads are spun up.