![]() |
|
how to add test to test set using vb script ? - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/forum-3.html) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/forum-6.html) +--- Thread: how to add test to test set using vb script ? (/thread-4093.html) |
how to add test to test set using vb script ? - dasappa - 12-02-2010 I was able to add test set but not able to add the test in QC. I would really appreciate if some one could help me on this issue. Below is the code I was trying to use. Please let me know if anyone need more inofrmation. Code: qcServer ="servername"
Set tdc = CreateObject("TDAPIOLE80.TDConnection")
If (tdc Is Nothing) Then
MsgBox "tdc empty"
Else
Msgbox "Connection object created"
End If
tdc.InitConnectionEx qcServer
tdc.Login "testlogin", "testpassword"
tdc.Connect "domain", "project"
Set TreeMgr = tdc.TreeManager
Set testF = tdc.TestFactory
Set labTreeMgr = tdc.TestSetTreeManager'----------------------------------------- ' Test Lab '------------------------------------------ Code: ' Get or create a test set folder.
errmsg = "Lab node error"
Dim tsFolder, tsFolderPath
tsFolder ="CWF_Regression"
tsFolderPath = "Root\" & tsFolder
On Error Resume Next
Set labFolder = labTreeMgr.NodeByPath(tsFolderPath)
' On Error GoTo LinkDefectsToEntitiesErr
If labFolder Is Nothing Then
Set labTreeRoot = labTreeMgr.Root
Set labFolder = labTreeRoot.AddNode(tsFolder)
labTreeRoot.Post
msgbox "Folder Created in TestLab"
Else
Set labTreeRoot = labTreeMgr.Root
Set labFolder = labTreeRoot.AddNode(tsFolder)
labTreeRoot.Post
msgbox "unable to create folder in test lab"
End If
' Get or create a test set from the factory of the new folder.
errmsg = "Test set error"
Dim tsName
TestName = "CWF_Regression"
tsName = TestName
Set testSetF = labFolder.TestSetFactory
Set aFilter = testSetF.Filter
aFilter.Filter("CY_CYCLE") = tsName
Set lst = testSetF.NewList(aFilter.Text)
If lst.Count = 0 Then
Set TstSet = testSetF.AddItem(Null)
TstSet.Field("CY_CYCLE") = tsName
TstSet.Post
Else
Set TstSet = lst.Item(1)
End If
' Get or create a test instance from the factory of the new test set.
Set NewTest = GetTest("C-BR1-FR10-TC1", "Subject\CWF_Regression")
msgbox NewTest.ID
Set NewTest = testF.AddItem(Null)
NewTest.Name = "C-BR1-FR10-TC1"
msgbox NewTest.ID
errmsg = "Test instance error"
Set testInstanceF = TstSet.TSTestFactory
Set aFilter = testInstanceF.Filter
aFilter.Filter("TC_TEST_ID") = NewTest.ID '"C-BR6-FR28-TC19"
Set lst = testInstanceF.NewList(aFilter.Text)
If lst.Count = 0 Then
Set tstInstance = testInstanceF.AddItem(Null)
' Put the new test in the test set.
tstInstance.Field("TC_TEST_ID") = NewTest.ID '"C-BR6-FR28-TC19"
Else
Set tstInstance = lst.Item(1)
End If
tstInstance.Status ="FAILED"RE: how to add test to test set using vb script ? - amitspandey - 01-20-2011 hi, Code: set qtpapp=CreateObject("Quicktest.Application")
qtpapp.Open "c:abc\test1"
qtpapp.Visible=True
qtpapp.Test Run
qtpapp.Quit
set qtpapp=Nothingwrite the code in any text file save the file with .vbs and run the file by double clicking on it. this code with run the mentioned test in the path above and close the qtp after execution. RE: how to add test to test set using vb script ? - sreekanth chilam - 01-21-2011 @HI Amit, The question was about the QC OTA(Open Test Architecture) and not about the AOM(Automation Object Model). @dasappa:I would suggest you to go thru OTA API reference file once, hope you can get the solution with that. RE: how to add test to test set using vb script ? - lbostic - 05-20-2011 Did you get a reply to this? One question where did GetTest() come from? Set NewTest = GetTest("C-BR1-FR10-TC1", "Subject\CWF_Regression") I just want to simply add a test to a test set... cannot find anywhere including in Documentation... LB RE: how to add test to test set using vb script ? - sunnystrikes - 08-15-2012 I'm also facing the same issue, can you please assist with codes for adding tests in the test instance. Thanks, Sunnhy If anyone has solution for this, please share it. Thanks. |