One Testing Center

QTP - Keyword Driven Framework. QTP Learning Book - Learn By Questions. QTP Learning Book - Made Easy - Part1. QTP Learning Book - Made Easy - Part2. QTP Quality Center - QC.

QTP - Frameworks

QTP - Frameworks. Record and Play back Framework. Action Driven Framework. Data Driven Framework. Functional Decomposition Framework. Keyword Driven Framework. Hybrid Framework. Test Driven Framework.

QTP - Automation

QTP - Basics. QTP - Intermediate. QTP - Advanced. QTP - Frameworks.

QTP - Training

Friends, Welcome to OneTestingCenter. I am HP Functional Test ExportOne. I am HP Automation Functional Test Certified Professional. I am certified for HP Functional Test 11.x. Happy to share my knowledge.

QTP - Books

QTP - Keyword Driven Framework. QTP Learning Book - Learn By Questions. QTP Learning Book - Made Easy - Part1. QTP Learning Book - Made Easy - Part2. QTP Quality Center.

Recent Post

Showing posts with label QTP - Files Comparison. Show all posts
Showing posts with label QTP - Files Comparison. Show all posts

QTP - Files Comparison


'************************************************************************
' QTP - Compare Files
'************************************************************************
path="C:"
file1="MyFile1.txt"
file2="MyFile2.txt"
Call CompareFiles(path, file1, file2)

Public Function CompareFiles(path, file1, file2)
Const ForReading = 1, ForWriting = 2, BinaryCompare = 1
Dim fso, MyFile1, MyFile2, comp, ln1, ln2
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile1 = fso.OpenTextFile(path & "\\" & file1, ForReading)
Set MyFile2 = fso.OpenTextFile(path & "\\" & file2, ForReading)
set DiffFile=fso.createtextfile("c:\diif.txt")
i=0
While MyFile1.AtEndOfStream <> True
ln1 = MyFile1.ReadLine
i=i+1
Wend
j=0
While MyFile2.AtEndOfStream <> True
ln2 = MyFile2.ReadLine
j=j+1
Wend
If i<>j Then
     Reporter.ReportEvent 1, "Line Count ", "Line Count is not equal."
 else
 Reporter.ReportEvent 0, "Line Count ", "Line Count is equal."
End If
MyFile1.Close
MyFile2.Close
Set MyFile1 = fso.OpenTextFile(path & "\\" & file1, ForReading)
Set MyFile2 = fso.OpenTextFile(path & "\\" & file2, ForReading)

Do While ((MyFile1.AtEndOfStream <> True) and (MyFile2.AtEndOfStream <> True))
l1=MyFile1.Line
l2=MyFile2.Line
ln1 = MyFile1.ReadLine
ln2 = MyFile2.ReadLine

comp = strcomp( cstr(ln1),cstr( ln2), BinaryCompare)
If (comp <> 0) then
 DiffFile.writeline l1&cstr(ln1)&"    "&cstr(ln2)
End if
Loop

MyFile1.Close
MyFile2.Close
DiffFile.close

End Function

'************************************************************************

QTP - Files Comparison


'***********************************************************************
' QTP - Compare Files
'***********************************************************************
path="C:"
file1="MyFile1.txt"
file2="MyFile2.txt"
Call CompareFiles(path, file1, file2)

Public Function CompareFiles(path, file1, file2)
Const ForReading = 1, ForWriting = 2, BinaryCompare = 1
Dim fso, MyFile1, MyFile2, comp, ln1, ln2
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile1 = fso.OpenTextFile(path & "\\" & file1, ForReading)
Set MyFile2 = fso.OpenTextFile(path & "\\" & file2, ForReading)
set DiffFile=fso.createtextfile("c:\diif.txt")
i=0
While MyFile1.AtEndOfStream <> True
ln1 = MyFile1.ReadLine
i=i+1
Wend
j=0
While MyFile2.AtEndOfStream <> True
ln2 = MyFile2.ReadLine
j=j+1
Wend
If i<>j Then
     Reporter.ReportEvent 1, "Line Count ", "Line Count is not equal."
 else
 Reporter.ReportEvent 0, "Line Count ", "Line Count is equal."
End If
MyFile1.Close
MyFile2.Close
Set MyFile1 = fso.OpenTextFile(path & "\\" & file1, ForReading)
Set MyFile2 = fso.OpenTextFile(path & "\\" & file2, ForReading)

Do While ((MyFile1.AtEndOfStream <> True) and (MyFile2.AtEndOfStream <> True))
l1=MyFile1.Line
l2=MyFile2.Line
ln1 = MyFile1.ReadLine
ln2 = MyFile2.ReadLine

comp = strcomp( cstr(ln1),cstr( ln2), BinaryCompare)
If (comp <> 0) then
 DiffFile.writeline l1&cstr(ln1)&"    "&cstr(ln2)
End if
Loop

MyFile1.Close
MyFile2.Close
DiffFile.close

End Function

'**********************************************************************

GAReddy @ OneTestingCenter @ All Articles