【问题标题】:Selenium Ruby script and HP ALM integrationSelenium Ruby 脚本和 HP ALM 集成
【发布时间】:2018-04-16 13:21:30
【问题描述】:

我正在研究 Selenium ALM 集成。 我有用 ruby​​ 开发的脚本,我想从 HP ALM 触发测试执行 selenium 脚本并将测试执行结果写回 HP ALM。 请帮我解决这个问题。

【问题讨论】:

    标签: ruby selenium integration alm hp-quality-center


    【解决方案1】:

    我认为你最好的选择是

    • 创建 VAPI-XP-TEST 类型的测试(您需要在创建测试时提及这一点,因为以后无法更改)
    • 然后,您需要提供脚本语言(VBScript 是不错的选择)
    • 然后,您需要提供测试类型,您的情况是 可能是控制台应用程序测试,其他选项是:COM/DCOM 服务器测试、Java 类测试、Web 服务 (Soap)、测试。
    • 然后,将“应用程序可执行文件”留空

    以上序列将创建初始脚本

    下面是使用上述方法创建的测试脚本(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)

    祝你好运:)

    【讨论】:

      猜你喜欢
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多