Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

How to add Attachments in QC during test script execution in QTP

Using below code, we can add attachment to QC during test script execution:

''This function will add the required attachment in QC, for Location defined by argument strLocationinQC

Function func_AddAttachmentToQC(FilePath,strLocationinQC)



On Error Resume next

If (ucase(strLocationinQC) = "TEST") Then

Set objCurrentTest = QCUtil.CurrentTest.Attachments

Set objAttach = objCurrentTest.AddItem(Null)

ElseIf(ucase(strLocationinQC) = "TESTSET") Then

Set objCurrentTest = QCUtil.CurrentTestSet.Attachments

Set objAttach = objCurrentTest.AddItem(Null)

ElseIf(ucase(strLocationinQC) = "TESTRUN") Then

Set objCurrentTest = QCUtil.CurrentRun.Attachments

Set objAttach = objCurrentTest.AddItem(Null)

End If

objAttach.FileName = strFilePath

objAttach.Type = 1

objAttach.Post

objAttach.Refresh

End Function

No comments:

Post a Comment