Author Topic: QC Unable to add the folder inside the folder Test Lab  (Read 15431 times)

Offline santhosh hc

  • Newbie
  • *
  • Posts: 11
  • QTP Automation Testing
QC Unable to add the folder inside the folder Test Lab
« on: December 17, 2009, 02:05:35 am »
Hi All

I am trying to add the folder structure to Test lab similar to the test plan tab folder structure.

i am able to create the parent folder but its failed to post the child folder i am getting below error.

Failed to Post the Folder.

Below is the code iam using.

Public QUID, QPass, TLFolderPath
Public QCConnection As Object
Public TestSetFact As Object
Sub Macro1()

Dim QCConnection
'Return the TDConnection object.
Set QCConnection = CreateObject("TDApiOle80.TDConnection")

Dim sUserName, sPassword
'********************************************************************
bSet fs = Nothing
'********************************************************************
sUserName = QUID 'ThisWorkbook.Sheets("Tests").Cells(2, 2) '<-- Change me.
sPassword = QPass 'ThisWorkbook.Sheets("Tests").Cells(3, 2) ' '<-- Change me.

QCConnection.InitConnectionEx "http://8080/qcbin" '<-- Change me.
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If

Dim sDomain, sProject
sDomain = "" '<-- Change me.
sProject = "" '<-- Change me.

QCConnection.Connect sDomain, sProject

If (QCConnection.Connected <> True) Then
MsgBox "QC Project Failed to Connect to " & sProject
WScript.Quit
End If

Call ExportTestCases("Subject\San_Test") '<-- Change me.

QCConnection.Logout
QCConnection.Disconnect
QCConnection.ReleaseConnection

End Sub
'Export test cases for the Test Lab node.
'
'@param: strNodeByPath String for the node path in Test Lab.
'
'@return: No return value.
Function ExportTestCases(strNodeByPath)
Set QCConnection = CreateObject("TDApiOle80.TDConnection")

Dim sUserName, sPassword
sUserName = QUID '<-- Change me.
sPassword = QPass

QCConnection.InitConnectionEx "http://:8080/qcbin" '<-- Change me.
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If

Dim sDomain, sProject
sDomain = "" '<-- Change me.
sProject = "" '<-- Change me.

QCConnection.Connect sDomain, sProject

'Call PrintFields(TestFactory)

Dim TreeMgr, TestTree, TestFactory, TestList
Set TreeMgr = QCConnection.TreeManager

'Specify the folder path in TestPlan, all the tests under that folder will be exported.
Set TestTree = TreeMgr.NodeByPath(strNodeByPath)
Set TestFactory = TestTree.TestFactory
Set TestList = TestFactory.NewList("") 'Get a list of all from node.

'Specify Array to contain all nodes of subject tree.
Dim NodesList()
ReDim Preserve NodesList(0)
'Assign root node of subject tree as NodeByPath node.
NodesList(0) = TestTree.Path

'Gets subnodes and return list in array NodesList
TLFolderPath = "Root\Z_Test"
Call GetNodesList(TestTree, NodesList)

Dim Row, Node, TestCase
Row = 2
For Each Node In NodesList
Set TestTree = TreeMgr.NodeByPath(Node)
Set TestFactory = TestTree.TestFactory
Set TestList = TestFactory.NewList("") 'Get a list of all from node.

'Iterate through all the tests.
For Each TestCase In TestList

'MsgBox TestCase.Field("TS_NAME")
'MsgBox TestCase.Field("TS_Test_ID")

Next
Next


Set TestList = Nothing
Set TestFactory = Nothing
Set TestTree = Nothing
Set TreeMgr = Nothing
'MsgBox "Done!!"
End Function


Public Function GetNodesList(ByVal Node, ByRef NodesList)
Set QCConnection = CreateObject("TDApiOle80.TDConnection")

Dim sUserName, sPassword
sUserName = QUID
sPassword = QPass
QCConnection.InitConnectionEx "http://" '<-- Change me.
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If

Dim sDomain, sProject
sDomain = " '<-- Change me.
sProject = "" '<-- Change me.

QCConnection.Connect sDomain, sProject
Dim i
'Run on all children nodes
For i = 1 To Node.Count
Dim NewUpper
'Add more space to dynamic array
NewUpper = UBound(NodesList) + 1
ReDim Preserve NodesList(NewUpper)


'****************************************
Set TestSetFact = QCConnection.testsetFactory
' Get the test set tree manager from the test set factory
Set tsTreeMgr = QCConnection.TestSetTreeManager
' Get the test set folder
Set tSetFolder = tsTreeMgr.NodeByPath("Root\Z_Test\San_Test1")
'Add the test set folder to above path
Set folder = tSetFolder.AddNode(Node)
folder.Post
'folder.Close
Set testSetF = folder.testsetFactory


'Set testSet1 = testSetF.AddItem(Null)
' testSet1.Name = ""
' testSet1.Post
' Set testSet2 = testSetF.AddItem(Null)
' testSet2.Name = ""
' testSet2.Post
'
'****************************************

'Add node path to array
NodesList(NewUpper) = Node.Child(i).Path

If Node.Child(i).Count >= 1 Then
TLFolderPath = folder.Path

Call QCChildNode(TLFolderPath, Node.Child(i))

' Call GetNodesList(Node.Child(i), NodesList)

End If
Next
End Function


Public Function QCChildNode(ByVal TLFolderPath As String, ByVal Clnode As String)
'Set QCConnection = CreateObject("TDApiOle80.TDConnection")

Dim sUserName, sPassword
sUserName = QUID
sPassword = QPass

QCConnection.InitConnectionEx "" '<-- Change me.
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If

Dim sDomain, sProject
sDomain = "" '<-- Change me.
sProject = "" '<-- Change me.

Set TestSetFact = QCConnection.testsetFactory
' Get the test set tree manager from the test set factory
Set tsTreeMgr = QCConnection.TestSetTreeManager
' Get the test set folder
Set tSetFolder = tsTreeMgr.NodeByPath(TLFolderPath)

'Add the test set folder to above path
Set folder = tSetFolder.AddNode(Clnode)
folder.Post
'folder.Close
Set testSetF = folder.testsetFactory


Set testSet1 = testSetF.AddItem(Null)

End Function

Thanks.

Offline Tarun Lalwani

  • Administrator
  • Hero Member
  • *****
  • Posts: 3025
    • KnowledgeInbox
Re: QC Unable to add the folder inside the folder Test Lab
« Reply #1 on: December 19, 2009, 11:23:12 pm »
On which line are you getting the error? it is difficult to judge the issue without more details
Regards,
Tarun
KnowledgeInbox Administrator

KnowledgeInbox" style="border:0