• Ruby 自动化数据驱动


    写了个新增功能的脚本,但此功能不允许增加同名记录。咋办?

            初始化时把相关记录删除掉?如果对业务不熟悉,对表结构不熟悉,主从表关系复杂,咋办?

            每次运行前手动改下驱动数据?麻烦!       

            想了个笨办法。

            先在excel驱动文件里加个事件:

    Private Sub Workbook_Activate()

    Sheet3.Cells(2, 6) = Sheet3.Cells(2, 6) + 1

    ThisWorkbook.Save

    End Sub

             然后在ruby脚本里加个方法:

      def open_excel(data_source)
        begin
          excel = WIN32OLE.new(“excel.application”)
          excel.visible = true
          workbook = excel.workbooks.open(data_source)
          workbook.close
          excel.Quit
        rescue =>e
          raise e
        end
      end

            最后在run_testcase中引用。

            简单讲:运行->ruby自动打开excel->excel对单元格数值自动加一并保存->ruby自动关闭excel

            好土吧?!应该有很多其它思路的,找时间再研究。

  • 相关阅读:
    (转载)MySQL日期时间函数大全
    Tcl commands
    Toplevel
    tk 8.4 commands
    iwidgets
    Options for Buttontype widgets
    Text Widget Options
    tk options
    itk_option
    Widget Options
  • 原文地址:https://www.cnblogs.com/chenxuan/p/1738412.html
Copyright © 2020-2023  润新知