Open jloyzaga opened 7 years ago
image missing icon showing where capture should be
If the image is showing with missing icon, it's probably because the path you specified wasn't right. I'm using the following method to capture screenshot:
public static void ScreenShot(IWebDriver driver, string imgName)
{
string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
string projectPath = new Uri(actualPath).LocalPath;
Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
ss.SaveAsFile(projectPath + @"com.seloger.resources\screenshots\" +imgName+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
In your test, just call the screenshot method then add the screenshot to the log.
ScreenShot(_driver, "exception");
_test.Log(LogStatus.Error, _test.AddScreenCapture(projectPath + @"com.seloger.resources\screenshots\exception.jpg"));
Your screenshots should be placed in the same location as your Extent report or the path of the screenshot should be relative to the path of your report
code is below `using AventStack.ExtentReports; using AventStack.ExtentReports.Reporter; using AventStack.ExtentReports.Reporter.Configuration; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using System;
namespace FrameworkForJoe { [TestFixture] public class SampleTest { private static IWebDriver driver; private static ExtentReports extent; private static ExtentHtmlReporter htmlReporter; private static ExtentTest test;
} `