question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Screenshots not always attaching to report

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:27 (21 by maintainers)

github_iconTop GitHub Comments

3reactions
jsa34commented, Apr 24, 2019

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!

3reactions
jsa34commented, Jan 4, 2019

Aha - so, now I am using:

@Override
    public void afterStepUpdate(StepResult result) {
            byte[] screenShot = ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES);
            Allure.getLifecycle().addAttachment(LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MMM-yy_hh:mm:ss")), "image/png", "png", screenShot);
    }

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found