| || |
Please suggest text comparison approach
After a long time, I have been working for an automation proposal, below is my situation, Please suggest better text comparison approach that fits this situation. Thanks in advance.
1. Reference folder has expected text file with its content
2. Actual file that will get generated during execution, will have almost the same content, with few dynamic value exceptions.
3. The above two files have to be compared and result report need to be generated. This is a repeated task for almost 1000 times/files at different test steps
4. I thought of using some existing comparison tools like UltraEdit, beyond Compare via GUI or API way *still in the analysis stage - where the tool helps us to generate good html/more reports.
Re: Please suggest text comparison approach
I am doing the same thing, comparing txt files, in my current automation project. I have all the verified files in a folder called Actual. I download and store the newly generated files are in a folder called New. Then I use Windows Word application to be invoked and compare the two files. If there are any differences, the file is written to a folder called Diff with the differences shown. You can iterate through as many files as you need, if you add the file names to your datatable. For my purpose, I am writing out the results to the Report Results. Is this kind of what you were looking for
Code for invoking Word object -
Set objApp = CreateObject("Word.Application")
objApp.Visible = False
objApp.Documents.Open ("give the Actual File Path here)")
objApp.ActiveDocument.Compare "give the New File Path here)", "DetectFormatChanges:=True"
Set revTemp = objApp.selection.NextRevision(True)
If Not (revTemp Is Nothing) Then
objApp.ActiveDocument.SaveAs "(give the Diff File Path here)"
reporter.ReportEvent micPass, "Compare TraceandError files", "Comparison is finished successfully - Differences found in Documents"
reporter.ReportEvent micFail, "Compare TraceandError files", "Comparison is finished successfully - No differences found in Documents"