Hello,
i would like to save a report for a single module in addition to the report for the entire run.
how can you implement this?
Sincerely yours
GeCi
Save a report for one module in a separate folder
Re: Save a report for one module in a separate folder
Hi,
I'm afraid there is no such option in Ranorex? So all you can probably do, is to write your own report logger. But this would most probably require a lot of coding?
Another possibility is to create a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
I'm afraid there is no such option in Ranorex? So all you can probably do, is to write your own report logger. But this would most probably require a lot of coding?
Another possibility is to create a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Save a report for one module in a separate folder
Hello,
many thanks for the help.
I solved it with an own logger.
Example:
And in the method "ITestModule.Run()" i use "Report.AttachLogger(customLogger);" and "Report.DetachLogger(customLogger);". In my first attempts this seems to work very well.
Sincerely yours
GeCi
many thanks for the help.
I solved it with an own logger.
Example:
Code: Select all
public sealed class CustomLogger : IReportLogger, IDisposable
{
private readonly string _fileName;
private readonly string _testName;
private XmlWriter _xmlWriter;
public CustomLogger(string fileName, string testName)
{
_fileName = fileName;
_testName = testName;
}
public void Start()
{
XmlWriterSettings settings = new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true };
_xmlWriter = XmlWriter.Create(_fileName, settings);
_xmlWriter.WriteDocType("html", null, string.Empty, null);
_xmlWriter.WriteStartElement("html");
_xmlWriter.WriteStartElement("head");
_xmlWriter.WriteStartElement("meta");
_xmlWriter.WriteAttributeString("charset", "UTF-8");
_xmlWriter.WriteEndElement();
_xmlWriter.WriteElementString("style",
"table {font - family: arial, sans - serif;border - collapse: collapse;width: 100 %;}" +
"td, th {border: 1px solid #dddddd;text - align: left;padding: 8px;}" +
"tr:nth-child(even) {background - color: #dddddd;}");
_xmlWriter.WriteElementString("title", $"Test {_testName}");
_xmlWriter.WriteEndElement();
_xmlWriter.WriteStartElement("body");
_xmlWriter.WriteStartElement("table");
}
public void End()
{
_xmlWriter.WriteEndElement();
_xmlWriter.WriteEndElement();
_xmlWriter.WriteEndElement();
}
public void LogText(ReportLevel level, string category, string message, bool escape, IDictionary<string, string> metaInfos)
{
WriteRow(level, category, message, null);
}
public void LogData(ReportLevel level, string category, string message, object data, IDictionary<string, string> metaInfos)
{
WriteRow(level, category, message, data);
}
public bool PreFilterMessages { get; set; }
private void WriteRow(ReportLevel level, string category, string message, object data)
{
_xmlWriter.WriteStartElement("tr");
if (level == ReportLevel.Failure || level == ReportLevel.Error)
{
_xmlWriter.WriteAttributeString("bgcolor", "#f58c8c");
}
else if (level == ReportLevel.Success)
{
_xmlWriter.WriteAttributeString("bgcolor", "#a7ec89");
}
else if (level == ReportLevel.Warn)
{
_xmlWriter.WriteAttributeString("bgcolor", "#f6c241");
}
WriteTableCell(level.ToString());
WriteTableCell(category);
WriteTableCell(message);
if (data != null)
{
if (data is Bitmap bitmap)
{
_xmlWriter.WriteStartElement("img");
using (MemoryStream memoryStream = new MemoryStream())
{
bitmap.Save(memoryStream, ImageFormat.Png);
byte[] byteImage = memoryStream.ToArray();
var base64 = Convert.ToBase64String(byteImage);
_xmlWriter.WriteAttributeString("style", "vertical-align: bottom;");
//_xmlWriter.WriteAttributeString("width", "100%");
//_xmlWriter.WriteAttributeString("height", "100%");
_xmlWriter.WriteAttributeString("src", $"data:image/png;base64,{base64}");
}
_xmlWriter.WriteEndElement();
}
else
{
throw new NotSupportedException($"{data} is not supported");
}
}
_xmlWriter.WriteEndElement();
}
private void WriteTableCell(string cellContent)
{
_xmlWriter.WriteStartElement("td");
if (!string.IsNullOrEmpty(cellContent))
{
_xmlWriter.WriteRaw(cellContent);
}
_xmlWriter.WriteEndElement();
}
public void Dispose()
{
_xmlWriter?.Dispose();
}
}
Sincerely yours
GeCi
Re: Save a report for one module in a separate folder
Hi,
Cool! Thanks for sharing your solution!
Cool! Thanks for sharing your solution!
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration