UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Absent Member.. Absent Member..
Absent Member..
1068 views

Retrieve the TS_TEST_ID from QTP

Jump to solution

I want to retrieve the TS_TEST_ID but i am not getting the testname TestFact.AddItem(TestName).

Please help.  I am using QTP 10, alm 11.00 patch 7.


 

Public Function fAddTest(TestName, Testid)

 

                Dim objTdConnection

                Dim objTestFactory

                Dim objTestList

                Dim objTest

                Dim strTestFactoryFilter

                Dim MyTest

 

                Set QCConnection = QCUtil.TDConnection

 

                'VerIfy If the test in the test plan otherwise it creates the test in the test plan as QTP type test

                Set TestFact = QCConnection.TestFactory

                Set MyTMgr = QCConnection.TreeManager

                Set MySRoot =MyTMgr.NodeByPath(Environment.Value("TEST_PLAN_PATH"))

                 

                strTestFactoryFilter = "select TS_TEST_ID from TEST where TS_NAME = '" & TestName & "' and TS_SUBJECT = " & MySRoot.NodeID

 

                Err.Clear

                On Error Resume Next

 

                Set objTestList = TestFact.NewList(strTestFactoryFilter)

 

                If Err.Number > 0 or objTestList.Count = 0 Then

                                Set MyTest = TestFact.AddItem(TestName)

                                MyTest.Field("TS_SUBJECT")= MySRoot.NodeID

                                MyTest.Field("TS_TYPE") ="QUICKTEST_TEST"

                                MyTest.Post

                                Testid = MyTest.id

                                fAddTest = True

                                Exit Function

                End If

 

                If objTestList.Count > 0 Then

                                TestFound = True

                                Set objTest = objTestList.Item(1)

                                Testid = objTest.id

 

                                Set TestSetF =  MyTest.TSTestFactory

                                Set MyTest = TestSetF.addItem(Testid)

                                MyTest.Status =Status

                                MyTest.Post

                End If

 

                fAddTest = True

 

End Function

0 Likes
1 Solution

Accepted Solutions
Absent Member.. Absent Member..
Absent Member..

I suggest you try this instead

If Err.Number > 0 or objTestList.Count = 0 Then
  Set MyTest = TestFact.AddItem(Null)
  MyTest.Name = TestName
  MyTest.Field("TS_SUBJECT")= MySRoot.NodeID
  MyTest.Type ="QUICKTEST_TEST"
  MyTest.Post
  Testid = MyTest.id
  fAddTest = True
  Exit Function
End If

 

 

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)

View solution in original post

0 Likes
3 Replies
Absent Member.. Absent Member..
Absent Member..

I suggest you try this instead

If Err.Number > 0 or objTestList.Count = 0 Then
  Set MyTest = TestFact.AddItem(Null)
  MyTest.Name = TestName
  MyTest.Field("TS_SUBJECT")= MySRoot.NodeID
  MyTest.Type ="QUICKTEST_TEST"
  MyTest.Post
  Testid = MyTest.id
  fAddTest = True
  Exit Function
End If

 

 

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)

View solution in original post

0 Likes
Absent Member.. Absent Member..
Absent Member..

Thanks a lot. It worked.

0 Likes
Absent Member.. Absent Member..
Absent Member..

Hi,

 

I have followed the similar steps mentioned.

 

I am trying to run the SQL to fetch the count on TS_STATUS for some specific dates using NODEID (TS_SUBJECT) from TestPlan (Test table) to populate in MS Excel2007 using macros. When I run the query "Failed to Get Test value" is the error description I am getting even when I change the query as "Select count(*) from Test" is also failing with same error. Trying checking QC connection but returns true for connection.

 

My script as below, request to please do the needful at the earliest.

 

 

            Set TestFact = oQCConn.TestFactory
            Set oQCTestTree = oQCConn.TreeManager
       
            Set folder = oQCTestTree.NodeByPath(aTestPlanValues(i))
           'TS_Status,
           strSQLQuery = "SELECT  count(*) as count FROM  Test where ts_subject =" & folder.NodeID & " and TS_CREATION_DATE " & _
                "Between '" & dtStartDate1 & "' and '" & dtEndDate1 & "' group by ts_Status"
    
           Err.Clear
           
            On Error Resume Next
            
            Set tList = TestFact.NewList(strSQLQuery)
           
       
        MsgBox Err.Description

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.