[英]Selenium Ruby script and HP ALM integration
我正在从事Selenium ALM集成。 我有使用ruby开发的脚本,我想从HP ALM触发测试执行硒脚本,并将测试执行结果写回到HP ALM。 请帮我。
我认为您最好的选择是
上面的序列将创建初始脚本
下面是使用上述方法创建的测试脚本(ALM端)的示例,在该示例中,我添加了代码以启动(请参见下面的代码添加)外部程序(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
上面是VBScript的示例,其中您的实际硒脚本为c:\\ test.rb(请参见上面的代码)
然后,您需要在测试实验室中创建一个测试实例,然后选择要运行的测试
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
您可以根据需要使用相同的test.rb或不同的test.rb。 我已经测试了上面的设置,并且对我有用(ALM 12.53)
祝好运 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.