• RSS
  • Facebook
  • Twitter

One Center for all the Testing Need. OneTestingCenter is for all, for all QA, for all Automation. Automation is easy, fun and enriching experience. Happy Learning and Happy Testing!

  • Access to All QA

    At OneTestingCenter, you find lots of books,articles,blogs and detailed guides. Everyone has access to QA. Happy Learning, Happy Testing.

  • Global Trainings

    All the QA/Auotmation trainings are available at OneTestingCenter. QA, Automation, QTP/UFT, Selenium, LoadRunner, QC/ALM, Appium...

  • Automation Learning Fun

    Technology is always evolving. Automation is always challenging. To be frank, Automation is fun, enthusiastic and enrching experience.

    '************************************************************************
    ' 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

    '************************************************************************
    Reactions:

    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

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