I also used the code to ignore the date timestamps but still it fails. If the date timestamp is same,the comparison passes but even after using this code,it fails.
function CompareFiles(fileName1, fileName2)
CompareFiles(fileName1, fileName2)
{
var fso, file1, file2, regEx;
var fileText1, fileText2, newText1, newText2;
var ForReading = 1;
// Creates the FileSystemObject object
fso = new ActiveXObject("Scripting.FileSystemObject");
// Reads the first text file
file1 = fso.OpenTextFile(fileName1, ForReading);
fileText1 = file1.ReadAll();
file1.Close();
// Reads the second text file
file2 = fso.OpenTextFile(fileName2, ForReading);
fileText2 = file2.ReadAll();
file2.Close();
// Specifies the regular expression pattern for the date/time mask
The date is in this format 4/15/2010 2:09 PM
regEx = /\d{1,2}.\d{1,2}.\d{2,4}\s\d{1,2}:\d{1,2}\s\w{2}/gim;
// Replaces the text matching the specified date/time format with <ignore>
newText1 = fileText1.replace(regEx, "<ignore>");
newText2 = fileText2.replace(regEx, "<ignore>");
// Compares the text
return (newText1 == newText2);
}
function Main()
{
var fileName1 = 'C:\\Bun211' + r2wdate + 'T000000.PDF';
var fileName2 = "C:\\Users\\sarya\\Documents\\TestComplete 7 Projects\\ClientRegression\\Bundler\\Stores\\Files\\Bun211.PDF";
if (CompareFiles(fileName1, fileName2))
Log.Message("The files are equal");
else
Log.Error("The files are different");
}
Thanks,
Sumedha