0

I am working on Selenium ALM integration. I have scripts which are developed in ruby and I want to trigger the test execution selenium scripts from HP ALM and write test execution result back to HP ALM. Please help me on this.

Brenda
  • 7
  • 1
  • 7

1 Answers1

0

I think your best option would be to

  • create a test of type VAPI-XP-TEST (you need to mention this at test creation as it cannot be changed later)
  • Then, you need to provide the script language (VBScript is as good option)
  • Then, you need to provide the test type which is your case is probably console application test, other options being : COM/DCOM server test, Java Class Test, Web Service (Soap), Test.
  • Then, leave the 'Application Executable File' empty

The above sequence will create the initial script

Below an example of a test script (ALM side) created with the above method in which I added the code to launch (see CODE ADDED below) an external program (ruby.exe)

' vbscript [VBScript]
' Created by Application Lifecycle Management
' 4/20/2018 16:34:54
' ====================================================


' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Application Lifecycle Management
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
  ' *** VBScript Limitation ! ***
  ' "On Error Resume Next" statement suppresses run-time script errors.
  ' To handle run-time error in a right way, you need to put "If Err.Number <> 0 Then"
  ' after each line of code that can cause such a run-time error.
  On Error Resume Next

  ' clear output window
  TDOutput.Clear

  ' TODO: put your code here
  ' === CODE ADDED START === 
  strCommandLine = "C:\\<pathtoyour ruby interpreter>\\bin\\ruby.exe c:\\test.rb" &  CurrentTSTest.name
  Set wshShell = CreateObject("WScript.Shell")
  iReturn = wshShell.Run(strCommandLine, 1, True)
  if iReturn = -1 then
    CurrentRun.Status = "Failed"
    CurrentTSTest.Status = "Failed"
  else
    CurrentRun.Status = "Passed"
    CurrentTSTest.Status = "Passed"
  end if
  ' === CODE ADDED END ===     

  If Not Debug Then
  End If
  ' handle run-time errors
  If Err.Number <> 0 Then
    TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description
    ' update execution status in "Test" mode
    If Not Debug Then
      CurrentRun.Status = "Failed"
      CurrentTSTest.Status = "Failed"
    End If
  End If
End Sub

The above is an example for VBScript where your actual selenium script is c:\test.rb (see in code above)

Then, you need to create a test instance in the test lab and select this test for running

example of test.rb

puts "running the script #{ARGV[0]}"
# put your test code here 
# in the end exit -1 => failure or 0 success
exit -1
#exit 0

You can use the same test.rb or different ones according to your needs. I've tested the above setup and it works for me (ALM 12.53)

Good Luck :)

kirkytullins
  • 143
  • 5