Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP code help
#1
Not Solved
Hi

I am using the below code to compare xml files in two different folders, the difference file is getting updated with the old one being erased even though I used the File append mode.[censored] Issue, quich response is much helpful and grateful. Below is

my code:

Code:
Function xmlcomp()

actualfolder = "C:\ERSTest\QTP\QTP_TASK\Post\"

expectedfolder = "C:\ERSTest\QTP\QTP_TASK\Pre\"

resultfolder = "C:\ERSTest\QTP\QTP_TASK\Result\"

Dim fso, f, fc, f1

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(expectedfolder)

Set fc = f.Files

For Each f1 in fc

expectedfile = expectedfolder +  f1.name

actualfile = actualfolder +  f1.Name

Set oXML1 = CreateObject("Msxml2.DOMDocument")
oXML1.load(expectedfile)

Set oXML2 = CreateObject("Msxml2.DOMDocument")
oXML2.load(actualfile)

Set XMLElements1= oXML1.DocumentElement.ChildNodes
Set XMLElements2= oXML2.DocumentElement.ChildNodes

If XMLElements1.length=XMLElements2.length Then

reporter.ReportEvent micPass,  "Child Nodes - Equal", "Pass"

   For i = 0 to XMLElements1.length-1

       If XMLElements1.item(i).Text <> XMLElements2.item(i).Text Then

reporter.ReportEvent micFail, "   Elements are not same- XML files are not equal", "Fail"

oXML2.save("C:\ERSTest\QTP\QTP_TASK\Result\errorfile.txt")

errorfile = "C:\ERSTest\QTP\QTP_TASK\Result\errorfile.txt"

err_update  "********************************************************************", errorfile

err_update "updates start here", errorfile

err_update "********************************************************************", errorfile

         Exit for

   end if
        
  Next

   reporter.ReportEvent micPass, "Elements  same- XML files are equal", "Pass"

else

   reporter.ReportEvent micFail, "Child Nodes - Not Equal- XML files are not equal", "Fail"  

End If

Next

End Function
----------------------------------------------------------------------------

Public Function err_update(errstring, errorfile)
  
   dim fileSource, MyFile
   Set fileSource = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fileSource.OpenTextFile(errorfile, 8, True)
       MyFile.WriteLine Date & " " & Time & " : " &errstring
   MyFile.Close

End Function
-----------------------------------------

Many thanks in advance
Maruti
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code to run all QTP scripts and see all results Pkapoor 11 18,019 08-15-2017, 02:58 AM
Last Post: Ravi
  QTP code structure Pkapoor 3 3,014 07-05-2013, 01:39 PM
Last Post: Staff
  QTP not generating code on web app Ace96 0 2,194 10-06-2012, 04:06 AM
Last Post: Ace96
  QTP: code is not working as expected mahi392 0 2,234 09-17-2012, 10:56 PM
Last Post: mahi392
  Is it possible to look at the QTP code that it has recorded? chong67 2 2,726 06-14-2012, 05:15 PM
Last Post: Shridevi.Salagare

Forum Jump:


Users browsing this thread: 1 Guest(s)