【发布时间】:2018-04-16 13:21:30
【问题描述】:
我正在研究 Selenium ALM 集成。 我有用 ruby 开发的脚本,我想从 HP ALM 触发测试执行 selenium 脚本并将测试执行结果写回 HP ALM。 请帮我解决这个问题。
【问题讨论】:
标签: ruby selenium integration alm hp-quality-center
我正在研究 Selenium ALM 集成。 我有用 ruby 开发的脚本,我想从 HP ALM 触发测试执行 selenium 脚本并将测试执行结果写回 HP ALM。 请帮我解决这个问题。
【问题讨论】:
标签: ruby selenium integration alm hp-quality-center
我认为你最好的选择是
以上序列将创建初始脚本
下面是使用上述方法创建的测试脚本(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 的示例,其中您的实际 selenium 脚本是 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)
祝你好运:)
【讨论】: