Creating XML Function Using QTP
'*******************************************************************************************************************************************
'* Function : CreateXML
'*******************************************************************************************************************************************
'Variable Declaration
Dim root
Dim BP
Dim TestSuite
Dim TestCase
Dim customReport
Public Function CreateXML()
'Initializing the file system object
Set objRootValue = createobject("scripting.FileSystemobject")
Dim logFileName
On Error Resume Next
'Getting the root values for ITAA Custom XML report
logFileName= "\\ittdevappw010\OPOM_Automation\Digital Life\DV_Portal_GlobalDataFiles\SUPPORT_FILES\testreport.txt"
If Not objRootValue.FileExists(logFileName) Then
fileMode = 2
Set logfile = objRootValue.opentextfile(logFileName,filemode,True)
logfile.writeLine("<?xml version='1.0'?>")
logfile.writeLine("<?xml-stylesheet href= '\\ittdevappw010\OPOM_Automation\Digital Life\DV_Portal_GlobalDataFiles\SUPPORT_FILES\Report.xsl' type='text/xsl'?>")
logfile.writeLine("<Report>")
logfile.writeLine("</Report>")
logfile.Close
End If
'Loading the Custom XML report
Set customReport = XMLUtil.CreateXML()
customReport.LoadFile logFileName
If Err.Number <> 0 Then 'Check the if there is an error
Reporter.ReportEvent micFail,"CreateXML","XML file creation has failed"
Environment.Value("ExecutionStatus") = "Failed"
Exit Function
Else
Reporter.ReportEvent micPass,"CreateXML","XML file creation has successfully done"
Environment.Value("ExecutionStatus") = "Passed"
End If
End Function
'*******************************************************************************************************************************************
'* Function : CreateXML
'*******************************************************************************************************************************************
'Variable Declaration
Dim root
Dim BP
Dim TestSuite
Dim TestCase
Dim customReport
Public Function CreateXML()
'Initializing the file system object
Set objRootValue = createobject("scripting.FileSystemobject")
Dim logFileName
On Error Resume Next
'Getting the root values for ITAA Custom XML report
logFileName= "\\ittdevappw010\OPOM_Automation\Digital Life\DV_Portal_GlobalDataFiles\SUPPORT_FILES\testreport.txt"
If Not objRootValue.FileExists(logFileName) Then
fileMode = 2
Set logfile = objRootValue.opentextfile(logFileName,filemode,True)
logfile.writeLine("<?xml version='1.0'?>")
logfile.writeLine("<?xml-stylesheet href= '\\ittdevappw010\OPOM_Automation\Digital Life\DV_Portal_GlobalDataFiles\SUPPORT_FILES\Report.xsl' type='text/xsl'?>")
logfile.writeLine("<Report>")
logfile.writeLine("</Report>")
logfile.Close
End If
'Loading the Custom XML report
Set customReport = XMLUtil.CreateXML()
customReport.LoadFile logFileName
If Err.Number <> 0 Then 'Check the if there is an error
Reporter.ReportEvent micFail,"CreateXML","XML file creation has failed"
Environment.Value("ExecutionStatus") = "Failed"
Exit Function
Else
Reporter.ReportEvent micPass,"CreateXML","XML file creation has successfully done"
Environment.Value("ExecutionStatus") = "Passed"
End If
End Function
No comments:
Post a Comment