I have a customized HTML(created thru XML/XSLT) test status report that basically lists the steps, results and comments of the results from executed automated scripts. Since I am still new to programming, I was wondering what are the best ways to get the captured screenshot(using the ITakesScreenshot in Selenium) filename and insert this filename in the XML node? My below code is for screenshot Capture:
public static void takeScreenShot()
{
string currentDate = DateTime.Now.ToString("ddd, ddMMMyyyy HHmm");
ITakesScreenshot screenshotHandler = Driver as ITakesScreenshot;
Screenshot screenshot = screenshotHandler.GetScreenshot();
string dir = @"C:\Documents\";
screenshot.SaveAsFile(dir + currentDate + fileName + ".png", ImageFormat.Png);
}
and below is my insert values on an XML node:
private static void InsertValues(string ID, string Step, string Result, string Comment)
{
var xmlDoc = XDocument.Load(xmltoLoad);
var newElement = new XElement("TestCase", new XAttribute("Id", ID),
new XElement("Screenshot", ""),
new XElement("Step", Step),
new XElement("Result", Result),
new XElement("Comments", Comment));
xmlDoc.Element("TestResults").Add(newElement);
xmlDoc.Save(xmltoLoad);
}
I was trying to do
string filename = screenshot.SaveAsFile(dir+currentDate+fileName+".png", ImageFormat.png);
But I receive an error that the void cannot be converted to string, which I understand. Is there something that I can do or are there any other approach on this?