Combined coded user interfaces HTML logs?

After running my tests on the encoded interface in Visual Studio 2012, I wanted the test results to be logged in an HTML file. After completing this tutorial, I was able to achieve this.

Unfortunately, each test receives its own HTML report in ..\TestResults\<Test Run Folder>\In\<Individual Test Log Folder>\<PC Name>\UITestActionLog.html , I currently have 3 different individual tests , and each gets its own folder in ..\TestResults\<Test Run Folder>\In\

Each resulting HTML file is as follows:

enter image description here

I want all 3 HTML files to be combined into one, and instead of just

Test 1

that would be like

Test 1

Test 2

Test 3

Is there a way to do this automatically with some configuration options, or am I stuck writing a program to combine all the HTML files myself?

+8
html c # visual-studio-2012 coded-ui-tests
source share
2 answers

I calculated the solution myself, wrote a program to take the <div class="g"> nodes from each HTML log and merge them into a single HTML file. It works like a charm.

+2
source share

I also wrote my own solution. After spending an hour using the HTML agility package, and discovering that it sometimes breaks with HTML5 embedded images, for example. ">, & L;".

I just wrote a console application that parsed htmls and integrated into 1:

cmd ActionLogBuilder inputfile's.html outputfile.html

(it is very raw, but it works)

 static void Main(string[] args) { bool only2 = false; StringBuilder outputFile = new StringBuilder(); if (args.Length == 2) { try { System.IO.File.Delete(args[1]); } catch { Console.WriteLine("No file to delete"); } System.IO.File.Move(args[0], args[1]); only2 = true; } int endArg = args.Length; Console.WriteLine(endArg.ToString()); int c = 0; if(!only2) { foreach (string a in args) { if (c == (endArg - 1)) { System.IO.TextWriter w = new System.IO.StreamWriter(a); w.Write(outputFile); w.Flush(); w.Close(); break; } else { if (c == 0) { using (StreamReader sr = new StreamReader(a)) { while (sr.Peek() >= 0) { string grabLine = sr.ReadLine(); if (grabLine.Contains("<div class=\"test-name\">Coded UI Test Log</div>")) { outputFile.AppendLine("<div class=\"test-name\">Test " + (c + 1).ToString() + "</div>"); } else { if (!grabLine.Contains("</body>") | !grabLine.Contains("</html>")) { outputFile.AppendLine(grabLine); } } } } } if (c != 0 && c != (endArg - 2)) { bool notYet = false; using (StreamReader sr = new StreamReader(a)) { while (sr.Peek() >= 0) { string grabLine = sr.ReadLine(); if (grabLine.Contains("<body>")) { notYet = true; } if (grabLine.Contains("<div class=\"test-name\">Coded UI Test Log</div>")) { outputFile.AppendLine("<div class=\"test-name\">Test " + (c + 1).ToString() + "</div>"); } else { if (notYet) { if (!grabLine.Contains("</body>") | !grabLine.Contains("</html>")) { outputFile.AppendLine(grabLine); } } } } } } if (c == (endArg - 2)) { bool notYet = false; using (StreamReader sr = new StreamReader(a)) { while (sr.Peek() >= 0) { string grabLine = sr.ReadLine(); if (grabLine.Contains("<body>")) { notYet = true; } if (notYet) { if (grabLine.Contains("<div class=\"test-name\">Coded UI Test Log</div>")) { outputFile.AppendLine("<div class=\"test-name\">Test " + (c + 1).ToString() + "</div>"); } else { outputFile.AppendLine(grabLine); } } } } } } c++; } } } 
+1
source share

All Articles