我正在生成版本4.0.3.0的范围报告,在该报告中,我将测试步骤记录在带有通过/失败消息以及屏幕截图的报告中。 生成报告后,对于各个测试步骤->屏幕截图图像显示得很小,无法正确看到。 ChromeBrower:屏幕截图以小尺寸显示。 IEBrowser:测试步骤不会显示屏幕截图。
请帮助我解决该问题的解决方案,以调整报告中屏幕截图的大小并在IE浏览器中显示屏幕截图。
下面是使用的代码:
public class MerlinBase : Base
{
#region Variables
public string commonDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
public string applicationconfigurationPath = AppDomain.CurrentDomain.BaseDirectory + "\\TestData\\Applicationconfigurations.xlsx";
public static ExtentReports extentReports;
public static ExtentTest extentTest;
#endregion Variables
#region Methods
/// <summary>
/// This method runs before start of each test
/// </summary>
[SetUp]
public void TestInitialize()
{
DataTable appDetails = ExcelUtilities.ReadExcel(applicationconfigurationPath,"ApplicationDetails");
string browserType = appDetails.Rows[0]["Browser"].ToString().Trim();
string appURL = appDetails.Rows[0]["URL"].ToString().Trim();
BrowserHandler.LaunchBrowser(browserType,commonDirectoryPath);
BrowserHandler.DeleteCookies();
BrowserHandler.NavigateToUrl(appURL);
BrowserHandler.MaximizeWindow();
string TestCaseName = testcontext.CurrentContext.Test.MethodName;
childDirectoryInfo.CreateSubdirectory(TestCaseName);
extentReports = new ExtentReports();
extentTest = extentReports.CreateTest(TestCaseName);
string pathToSaveExtentReport = reportParentFolderPath + "\\" + reportChildFolderPath;
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(pathToSaveExtentReport +"\\"+"AutomationReport"+".html");
extentReports.AttachReporter(htmlReporter);
}
public static class ExtentReporting
{
static string Screenshot = null;
public static void Success(this ExtentTest Test,string PassDetails,MediaEntityModelProvider provider = null)
{
try
{
Screenshot = TakeScreenshot.ScreenshotOfTestStep();
if (Screenshot != null)
{
var m = MediaEntityBuilder.CreateScreenCaptureFromPath(Screenshot).Build();
Test.Pass(PassDetails,m);
}
}
catch (Exception ex)
{
throw ex;
}
}
}