10-26-2009, 03:22 PM
Hi Venkat,
Thanks for Replying. I used the same Quote for xml comparision, but in our portal there are some mandatory fields and automatically it creates XML tags when a file is exported.Now if a file is uploaded with invalid data for the field which is mandatory and if exported ,a tag is being generated with out a value .Now if i add a check point for xml comparision it must show the difference in the values.
If there is one difference between the uploaded and Exptoreted file, it is showing the difference. But it is not working fine when there are multiple differences present.
Code used in test case:---------
'======Checking for the Particular child for which there is a difference======
Thanks for Replying. I used the same Quote for xml comparision, but in our portal there are some mandatory fields and automatically it creates XML tags when a file is exported.Now if a file is uploaded with invalid data for the field which is mandatory and if exported ,a tag is being generated with out a value .Now if i add a check point for xml comparision it must show the difference in the values.
If there is one difference between the uploaded and Exptoreted file, it is showing the difference. But it is not working fine when there are multiple differences present.
Code used in test case:---------
Code:
Dim description, filepath
Set xmlDoc1 = CreateObject("Msxml2.DOMDocument")
xmlDoc1.load("C:\Documents and Settings\Ramakrishna\QTP\Qtp Tests\EzLynx Portal\Test Data\Upload\Auto.xml")
Set xmlDoc2 = CreateObject("Msxml2.DOMDocument")
xmlDoc2.load("C:\Documents and Settings\Ramakrishna\QTP\Qtp Tests\EzLynx Portal\Test Data\ExportFile\App1.xml")
Set ElemList1= xmlDoc1.DocumentElement.ChildNodes
Set ElemList2= xmlDoc2.DocumentElement.ChildNodes
If ElemList1.length=ElemList2.length Then
Else
For i = 0 to ElemList1.length-1
If ElemList1.item(i).Text=ElemList2.item(i).Text Then
' msgbox
Reporter.ReportEvent micPass,"Checking for Child Elements","child element:"&i &" is same in both XML files"
Else
' msgbox
Reporter.ReportEvent micFail,"Checking for Child Elements","child element:"& i &" is not same in both the XML files, In XML file 1, The valueis: "& ElemList1.item(i).Text &" and In XML file 2, The valueis:"&ElemList2.item(i).Text
' msgbox ElemList1.item(i).nodeName
Code:
Set ElemChildList1 = ElemList1.item(i).ChildNodes
Set ElemChildList2 = ElemList2.item(i).ChildNodes
' msgbox ElemChildList.length
For J = 0 to ElemChildList1.length-1
If ElemChildList1.item(J).Text=ElemChildList2.item(J).Text Then
Reporter.ReportEvent micPass,"Checking for Error Field","There is no Difference in the Files"
Else
Reporter.ReportEvent micFail,"Checking for Error Field","child element:"& ElemChildList1.item(J).nodeName&"is not same in both the XML files, In XML file 1, The value is:"&ElemChildList1.item(J).Text&"and In XML file 2, The value is:"&ElemChildList2.item(J).Text
End If
Next
End If
Next
End If