HTML:无法在html报告中查看base64图像 [英] HTML : Unable to view the base64 image in html report

查看:106
本文介绍了HTML:无法在html报告中查看base64图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在硒中,我通过javamail API自动发送范围报告.我正在使用base 64编码器来生成屏幕截图并将其附加到报告中.问题是屏幕截图显示为缩略图,但是当我缩放它时,它将显示编码的图像.

解决方案

我已经在Selenium C#中完成了此操作,您可以进行修改以在Java中使用它:

您只需要将图像转换为Base64图像并使用媒体实体构建器即可.

 截屏文件=((ITakesScreenshot)驱动程序).GetScreenshot();字符串图像= file.AsBase64EncodedString;exTest.Pass(msg,MediaEntityBuilder.CreateScreenCaptureFromBase64String(image).Build());System.Diagnostics.Trace.WriteLine("PASS>>>" + msg); 

In selenium I am auto mailing the extent reports through javamail API. I am using base 64 encoder to generate screenshots and attach to the report. The issue is the screenshot is visible as thumbnail but when i zoom it, it displays the encoded image.enter image description here

String scnShot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64);
String s="data:image/png;base64,"+scnShot;
test.log(LogStatus.INFO,test.addScreenCapture(s));

解决方案

I have done this in selenium C#, you can modify to use this in Java:

You just need to convert the image to Base64 image and use Media entity builder.

Screenshot file = ((ITakesScreenshot)driver).GetScreenshot();
string image = file.AsBase64EncodedString;

exTest.Pass(msg, MediaEntityBuilder.CreateScreenCaptureFromBase64String(image).Build());
System.Diagnostics.Trace.WriteLine("PASS >>>>  " + msg);

这篇关于HTML:无法在html报告中查看base64图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆