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

Adding log details even when the log has only media. #404

Closed

Conversation

Rakshas7
Copy link

@Rakshas7 Rakshas7 commented Sep 4, 2023

Added log.getDetails() to test log when the condition log.hasMedia() is satisfied. This will add log details to extent report when only the screenshot is appended to a log.

@anshooarora
Copy link
Member

I started working on this, but just realized that the latest master already has this built-in, see below:

    private void constructLog(final Log log, final ExtentTest extentTest, final ExceptionInfo ex) {
        final Media m = log.getMedia();

        if (m != null) {
            if (m.getPath() != null) {
                extentTest.log(log.getStatus(),
                        MediaEntityBuilder.createScreenCaptureFromPath(m.getPath()).build());
            }
            if (((ScreenCapture) m).getBase64() != null) {
                extentTest.log(log.getStatus(),
                        MediaEntityBuilder.createScreenCaptureFromBase64String(((ScreenCapture) m).getBase64()).build());
            }
        }

        if (ex != null) {
            if (!extentTest.getModel().hasLog()) {
                extentTest.log(log.getStatus(), log.getDetails());
            }

            final List<Log> logs = extentTest.getModel().getLogs();
            final Log lastLog = logs.get(logs.size() - 1);
            lastLog.setException(ex);
            extentTest.getModel().getExceptions().add(ex);
        }
    }

Thanks for your efforts. :)

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

Successfully merging this pull request may close these issues.

2 participants