Thursday, 17 January 2013

Capture Test Step in QTP

Capture Test Step in QTP

Public Function Add_Attachment_Step(FilePath)
Set MyStep = qcutil.CurrentRun.StepFactory.AddItem(null)
MyStep.Field("ST_STEP_NAME")="My Step "
MyStep.Field("ST_STATUS") = "Failed"
MyStep.Field("ST_DESCRIPTION") = "My Step Description"
MyStep.Field("ST_EXPECTED") = "My Step Expected Result"
MyStep.Field("ST_ACTUAL") = "My Step Actual Result"
MyStep.Post
set oStepsList = QCUtil.CurrentRun.StepFactory.NewList("")
'get the Count of steps
iStepCount = oStepsList.Count
'Now can add the attachment to the recently added step
Set ObjCurrentTest = QCUtil.CurrentRun.StepFactory.NewList("").Item(iStepCount)
Set Attachment_Factory = ObjCurrentTest.attachments
Set ObjAttach = Attachment_Factory.AddItem(null)
ObjAttach.Filename = FilePath
ObjAttach.Type=1
ObjAttach.Post
ObjAttach.Refresh
Set oStepsList  = nothing
Set ObjCurrentTest = nothing
Set Attachment_Factory = nothing
Set ObjAttach = nothing
Set MyStep = nothing
End Function

No comments:

Post a Comment