Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] Copy and Paste using scripts
01-12-2012, 06:44 PM
Post: #1
[Help] Copy and Paste using scripts

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
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

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

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.
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
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)