Inserting a screenshot image filename in Selenium to XML using c# -
i have customized html(created thru xml/xslt) test status report lists steps, results , comments of results executed automated scripts. since still new programming, wondering best ways captured screenshot(using itakesscreenshot in selenium) filename , insert filename in xml node? below code screenshot capture:
public static void takescreenshot() { string currentdate = datetime.now.tostring("ddd, ddmmmyyyy hhmm"); itakesscreenshot screenshothandler = driver itakesscreenshot; screenshot screenshot = screenshothandler.getscreenshot(); string dir = @"c:\documents\"; screenshot.saveasfile(dir + currentdate + filename + ".png", imageformat.png); } and below insert values on 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 trying
string filename = screenshot.saveasfile(dir+currentdate+filename+".png", imageformat.png); but receive error void cannot converted string, understand. there can or there other approach on this?
.saveasfile() doesn't return there no return stuff filename. there reason can't do
string filename = dir + currentdate + filename + ".png"; screenshot.saveasfile(filename, imageformat.png);
Comments
Post a Comment