| || |
- 1 Post By tclasp
Test Steps Updated in the Same Test Case
I have tried to upload a test case from excel to QC using VBA code,while uploading the test case the steps for the second test case were updated in the first test case itslef and not a new second test case has been created, Please find the below code for your reference and help me out to fix it
If (objTCFile.Type = "Microsoft Excel Worksheet" Or objTCFile.Type = "Microsoft Excel 97-2003 Worksheet") Then
Set objExcel = CreateObject("Excel.Application")
Set objWB = objExcel.Workbooks.Open(objTCFile.Path)
Set objSheet = objWB.Worksheets(1)
LRow = objSheet.Cells.Find(What:="*", After:=objSheet.Range("A1"), Lookat:=xlWhole, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
strTCName = objSheet.Cells(2, 2)
strTCDescription = objSheet.Cells(2, 3)
Set objQCTreeMgr = objQCConnObject.TreeManager
Set objQCNodePath = objQCTreeMgr.NodeByPath(strQCFolderPath)
Set objTestFact = objQCNodePath.TestFactory
Set objNewTC = objTestFact.AddItem(Null)
objNewTC.Name = strTCName
objNewTC.Field("TS_DESCRIPTION") = strTCDescription
objNewTC.Type = "MANUAL"
Set objDesignFact = objNewTC.DesignStepFactory
' For intExcelRow = 2 To objSheet.UsedRange.Rows.Count
For intExcelRow = 2 To LRow
Set objDesignStep = objDesignFact.AddItem(Null)
If Trim(objSheet.Cells(intExcelRow, 4)) <> "" Then
objDesignStep.StepName = objSheet.Cells(intExcelRow, 4)
objDesignStep.StepDescription = objSheet.Cells(intExcelRow, 5)
objDesignStep.StepExpectedResult = objSheet.Cells(intExcelRow, 6)
objDesignStep.Field("DS_USER_07") = objSheet.Cells(intExcelRow, 7)
ElseIf Trim(objSheet.Cells(intExcelRow, 4)) = "" Then
Set objSheet = Nothing
objExcel.DisplayAlerts = False
Set objWB = Nothing
Set objExcel = Nothing
Where in your code do you expect a second test to be created?
You only have one line that creates a test [Set objNewTC = objTestFact.AddItem(Null)] and it is not part of a loop that would ever cause it to be executed again.
From row 2 onwards, every design step is being added to the same test.
... just another Tester ...
Great minds think alike. I gave the author basically the same response in their post on the HP Community.
Test Steps Updated in the Same Test Case - HP Enterprise Business Community
(Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)
Hi Irvine, am an amateur in vba would you pls help me out in how to implement the loop inside the code
The first thing you need to do is figure out how to tell when you've reached the end of test 1 - i.e. where does test 2 begin, test 3.. etc
But I'm intrigued, and Trudy has already asked on the HP forum, why not just use the Excel addin that already exists?
... just another Tester ...