Showing posts with label QTP Web Service. Show all posts
Showing posts with label QTP Web Service. Show all posts

Friday, February 4, 2011

XML Web Service Automation Testing

Below code show the web service testing without qtp Add-in

Click here for webService XML file Weather Forecast Web Service Link
For Excel file Mail me.. neerajlad171@gmail.com

Dim counter
counter = 1
Dim CommonfilePath, ExcelSheetName, DataSheetNo, DataSheetName
CommonfilePath = "D:\QTP_Practive\WebServices\SampleData_1.xls"
DataSheetName = "OutputWeatherFC"
DataSheetNo = DataTable.GetSheetCount + 1
ExcelSheetName = "OutputWeatherFC"
Call ImportData(CommonfilePath, ExcelSheetName, DataSheetNo, DataSheetName)

Dim xmldoc
Set xmldoc = CreateObject("msxml2.domdocument")
xmldoc.Load ("D:\QTP_Practive\WebServices\Response_WeatherByPlaceName.xml")
dtTopNode = DataTable.Value("TAGNAME", DataSheetName)
dtTags = DataTable.Value("TAGS", DataSheetName)
dtTagName = GetdtNodeName(dtTopNode)
Set TopNode = xmldoc.documentElement
MsgBox TopNode.nodeName
Call TreeTravel(TopNode, dtTagName, dtTags)
 
Function TreeTravel(TopNode, dtTagName, dtTags)
    If dtTags = "END" Then
       counter = counter + 1
       DataTable.SetCurrentRow (counter)
       dtTopNode = DataTable.Value("TAGNAME", DataSheetName)
      dtTags = DataTable.Value("TAGS", DataSheetName)
      dtTagName = GetdtNodeName(dtTopNode)
    Else
      If TopNode.nodetype = 1 Then
           If TopNode.nodeName = dtTagName And dtTags = "" Then
                  MsgBox TopNode.nodeName & " <=> " & TopNode.Text
           End If
           Set child = TopNode.childNodes
           ' msgbox "TopNode Name: " &TopNode.nodename
          For i = 0 To child.length - 1
                 If child.Item(i).nodetype <> 3 Then
                          counter = counter + 1
                          DataTable.SetCurrentRow (counter)
                          dtTopNode = DataTable.Value("TAGNAME", DataSheetName)
                          dtTags = DataTable.Value("TAGS", DataSheetName)
                          dtTagName = GetdtNodeName(dtTopNode)
                         Call TreeTravel(child.Item(i), dtTagName, dtTags)
                End If
           Next
     End If
  End If
End Function