Code to copy a test set from one folder to another in Quality Center



I am sharing this info as I had to do quite a research before i found the solution.

Problem:  Copy a test set from one folder to another in Quality Center test lab using code.

First things first: This cannot be coded in vbscript or QTP as it uses the ISupportCopyPaste interface and the CopyToClipboard method which is part of this interface. Therefore you cannot declare a statement like Dim iscp As ISupportCopyPaste

A simpler way would be to use vba and do the following:

1. Add the following code in excel vba editor.
2. Add the "OTA COM Type Library" as a reference under tools -> references from excel.
3. Run and enjoy the magic :-)

Solution:

Public Function CopyPasteTestSetFolder(sourceFolderPath, destFolderPath)
       
     strServer = "http://xyz/qcbin"
     strDomain = ""
     strProject = ""
     strUser = ""
     strPassword = ""
     
     Set objTDConnection = CreateObject("tdapiole80.TDCONNECTION")
     objTDConnection.InitConnection strServer, strDomain
     objTDConnection.ConnectProject strProject, strUser, strPassword
   
     Set objTreeManager = objTDConnection.TestSetTreeManager
     Set sourceFolder = objTreeManager.NodeByPath(sourceFolderPath)
     Set destFolder = objTreeManager.NodeByPath(destFolderPath)
   
     Dim iscp As ISupportCopyPaste
         
     Set iscp = sourceFolder

     clipboard = iscp.CopyToClipBoard(sourceFolder.NodeID, 0, sourceFolderPath)

     Set iscp = destFolder
     iscp.PasteFromClipBoard clipboard, destFolder.NodeID, 0, -1

     Set treeMng = Nothing
     Set sourceFolder = Nothing
     Set destFolder = Nothing
     Set iscp = Nothing
   
End Function


Happy Testing!

Comments

  1. hi,

    Looking for a aladdin.jar file. Please help in providing this jar to work with oracle forms 11g tabbed items

    ReplyDelete
  2. Anonymous25/9/12

    Excellent! Thank you so much for the info!!!

    ReplyDelete
  3. Glad that helped!

    Best Regards,
    Ady.
    "Quality cannot be sprinkled onto an application right before it gets exposed to your clients"
    Technology Specific Guide For QTP - My new Book on QTP

    ReplyDelete
  4. Hi Aditya,

    Thanks for your code. But is there any way that we can achieve this through QTP..?

    Regards,
    Suman CH

    ReplyDelete
  5. Anonymous3/4/13

    Hi Aditya,
    On the same note , can we add scripts from test plan to a Test set under test lab of QC V 10 , using VBA code ?

    Regards,
    AD

    ReplyDelete
  6. Hi AD,

    I am sure thats very much possible using OTA, will have to dig a little to see if i have some reusable code.
    Let me know if you need help.

    Best Regards,
    Ady

    ReplyDelete
  7. Is it possible to copy testcases from one server test plan to another lam server test plan?
    ie: archival

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?