Files.Compare returns exception
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Files.Compare returns exception
I am trying to comapre two pdf documents. I used this in my script but when I run this code,it gives me an exception as " 'Files' is undefined" .Is this not the correct way to comapre files?
Files.Compare("C:\\myfiles\\Bun26.PDF",'C:\\Bun26' + r2wdate + 'T000000.PDF');
Thanks.
Sumedha
.Compare("C:\\myfiles\\Bun26.PDF",'C:\\Bun26' + r2wdate + 'T000000.PDF');Thanks.Sumedha
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
sumedha
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have one more doubt. I compared two files ,both look to be same but somehow the file comparison from test complete gives me error with some hash value.
The files "C:\tcfiles\bundler\Bun29.PDF" and "C:\Bun292010-04-15T000000.PDF" are not equal. HashValue = 36820037.
So can we not come to know particularly where the comparison failed in whole report ?
Thanks,
Sumedha
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sumedha,
Please send us the target PDF files. We'll try to create a sample script for you.
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
