01-12-2012, 06:44 PM
Hi,
Since two days I'm trying to do simple thing. But It does not look so simple with QTP. Namely I want to read an. xml file then store/copy text and paste it in a text fields in a browser. I couldn't find any help. Google says almost nothing about it.
First i download a file from Quality Center
'Where to save and resource name
Then update it
'Step 1 - open .xml file and save
'Step 2 - Set fields value
'Step 3 - Save results
xmlDoc.Save(XMLNewFile)
Then I read it and make a print log but I don't really know if this point is necessary.
I just need one more point to copy the .xml text and paste it.
Thx in advance for your help
Matt
Since two days I'm trying to do simple thing. But It does not look so simple with QTP. Namely I want to read an. xml file then store/copy text and paste it in a text fields in a browser. I couldn't find any help. Google says almost nothing about it.
First i download a file from Quality Center
'Where to save and resource name
Code:
saveTo = "C:\PROMPT\QTP"
resourceName = "SCQ_2nd_loop.xml"
Set qcConn = QCUtil.QCConnection
Set oResource = qcConn.QCResourceFactory
Set oFilter = oResource.Filter
oFilter.Filter("RSC_FILE_NAME") = resourceName
Set oResourceList = oFilter.NewList
If oResourceList.Count = 1 Then
Set oFile = oResourceList.Item(1)
oFile.FileName = resourceName
oFile.DownloadResource saveTo, True
End If
Then update it
'Step 1 - open .xml file and save
Code:
Const XMLDataFile = "C:\PROMPT\QTP\SCQ_2nd_loop.xml"
Const XMLNewFile = "C:\PROMPT\QTP\SCQ_2nd_loop_update_01.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(XMLDataFile)
'Step 2 - Set fields value
Code:
Set node = xmlDoc.SelectSingleNode("/ProductMaintenance/ProductMaintenancePlan/ProductMaintenanceQuotation/ProductMaintenanceQuotationNumber")
node.Text = "QN10013A"
'Step 3 - Save results
xmlDoc.Save(XMLNewFile)
Then I read it and make a print log but I don't really know if this point is necessary.
Code:
Const XMLDataFile = "C:\PROMPT\QTP\SCQ_2nd_loop_update_01.xml"
Set xmlObj = XMLUtil.CreateXML()
xmlObj.LoadFile("C:\PROMPT\QTP\SCQ_2nd_loop_update_01.xml")
Print xmlObj.ToString()
I just need one more point to copy the .xml text and paste it.
Thx in advance for your help
Matt