Unnikrishnan V
Unnikrishnan V

Reputation: 37

Robot Framework and HPQC integration

I am trying to integrate HP Application Lifecycle Management (HP ALM) with Robot Framework using VAPI-XP tool inside HP ALM. I want to know whether anyone of you have tried this before, and if so please share your approach.

Regards, Unni

Upvotes: 1

Views: 2039

Answers (1)

Damodharan
Damodharan

Reputation: 16

I am posting the script (VBScript to be written inside the VAPI-XP Testscript pane) which i have created for my project to integrate Robot FW with Quality Center. This will create a dyanamic batch command line file, execute the robot framework script when the script triggered from QC and post the RF html result files as an attachment to the QC Test run instance.

You can go through the script and modify based on your need.

Thanks, Damodharan B

' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
  On Error Resume Next
  TDOutput.Clear

  ' Run Test
  strMainDir = "C:\Robot-QC"
  strTestDir = strMainDir & "\Execution"
  strBatchFileDir = strTestDir & "\BatchFiles"
  strResultDir = strTestDir & "\Results"

  strTestName = "TestCase1"
  strResultPath = strResultDir & "\" & strTestName & "_Res"
  strExecutionLogPath = strResultPath & "\ExecutionLog.txt"

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  If objFSO.FolderExists(strResultPath) Then
     objFSO.DeleteFolder strResultPath, True
  End If
  objFSO.CreateFolder strResultPath

  'If Execution Directly From QC, Creates Test Batch File
  If Not objFSO.FileExist(strBatchFileDir & "\" & strTestName & ".bat")Then
     'Write Batch File for Test
     Set objTestBatchFile = objFSO.OpenTextFile(strBatchFileDir & "\" & strTestName & ".bat", 2, True)
     objTestBatchFile.WriteLine "cd " & strTestDir
     objTestBatchFile.WriteLine "pybot -t " & strTestName & " --outputdir Results\" & strTestName & "_Res " & "TestCases.txt"
     objTestBatchFile.Close
     Set objTestBatchFile = Nothing
  End If

  XTools.run strBatchFileDir & "\" & strTestName & ".bat", "", -1
  XTools.Sleep 1000

  ' Update Run Status
  strTDOutPut = Replace(TDOutput.Text, " ", "")
  If InStr(1, strTDOutPut, strTestName & "|PASS|") = 0 Then
     CurrentRun.Status = "Failed"
     CurrentTSTest.Status = "Failed"
  End If
  'Log Command Prompt Output
  Call Log_Output(objFSO,strExecutionLogPath)

  'Upload Result Files
  Set objFolder = objFSO.GetFolder(strResultPath & "\")
  Set objFiles = objFolder.Files

  For Each oFile In objFiles
       Set objRunAttach = CurrentRun.Attachments
       Set newAtt = objRunAttach.AddItem(Null)
       newAtt.FileName = strResultPath & "\" & oFile.Name
       newAtt.Type = 1
       newAtt.Post
       newAtt.Refresh
  Next

  Set newAtt = Nothing
  Set objRunAttach = Nothing
  Set objFiles = Nothing
  Set objFolder = Nothing
  Set objFSO = Nothing

  Err.Clear
  On Error Goto 0
End Sub

Sub Log_Output(objFSO,strExecutionLogPath)
   Set objOutputFile = objFSO.OpenTextFile(strExecutionLogPath, 2, True)
   objOutputFile.Write TDOutput.Text
   objOutputFile.Close
   Set objOutputFile = Nothing
End Sub

Upvotes: 0

Related Questions