Remove automation screenshots in bulk

  • Questions
  • Remove automation screenshots in bulk
Question ID: 104892

Our automation team records screenshots on each step for validation purposes. This creates a lot of extra attachments being stored on each run. Does anyone have a method for removing these attachments in bulk so that we can reduce the server storage?

Marked as spam
Posted by (Questions: 122, Answers: 3)
Asked on March 12, 2013 7:18 pm
Answers (2)
Private answer

Thanks Jafar.

That worked perfectly.

Marked as spam
Posted by (Questions: 122, Answers: 3)
Answered on March 12, 2013 7:23 pm
Private answer


Here is a script that I came up with for the same purpose. You can save this as a .vbs file and run. You will need to edit the script and input your server information at the top.

On Error Resume Next

Dim qcServer, qcDomain, qcProject, qcUser, qcPassword, qc, RunID, RunFact, Runobj, AttachFact, AttachCol, mycount, Attachobj, AttachedName

'Set variables for QC connection
    qcServer =   
    qcDomain =   
    qcProject =  
    qcUser =     
    qcPassword = 
Set qc = CreateObject(''tdapiole80.tdconnection'')

'Check to see that the tdc object exists
    If qc Is Nothing Then
        MsgBox ''The qc object is empty''
    End If

'Establish the connection and log in
    qc.InitConnectionEx qcServer
    qc.Login qcUser, qcPassword
    qc.Connect qcDomain, qcProject

'Get the RunID from user input.
RunID = InputBox(''Delete Attachments from which Run ID?'', ''Delete Run Attachments'')

'Set the objects needed to get to the Attachment object.
Set RunFact = qc.RunFactory
Set Runobj = RunFact.Item(RunID)
Set AttachFact = Runobj.Attachments
Set AttachCol = AttachFact.NewList('''')

'Get a count of attachments for the RunID
mycount = AttachCol.Count

	'Iterate through the attachments
	For i = 1 to mycount
		'Set the attachment item into an object
    	Set Attachobj = AttachCol.Item(i)
			'Get the name property of the attachment			
			AttachedName = Attachobj.Name(1)
			'strip the name to just the first 18 characters
			AttachedName = left(AttachedName, 18)
			'check to see if the stripped string is ''ReporterScreenShot''
			If AttachedName = ''ReporterScreenShot'' Then
				'If true, then delete the attachment.
			End If
		'Kill the object to free up for next iteration
		Set Attachobj = Nothing
'Disconnect from Quality Center
If qc.Connected = True Then
End If

'Log off the server and release the Connection.
If qc.LoggedIn Then
End If

'Kill The objects.
Set AttachCol = Nothing 
Set AttachFact = Nothing
Set Runobj = Nothing
Set RunFact = Nothing
Set qc = Nothing

'Inform the user that the script completed.
MsgBox ''Script Complete.''

On Error GoTo 0

Marked as spam
Posted by (Questions: 3, Answers: 168)
Answered on March 12, 2013 7:22 pm