• 封装几个有用的QTP函数


    作者:iamfeiyu1009


    ************************************************************
    '@Descriptionweblist随机选择且返回选择的值
    '@Documentationtest_object:object即weblist
    '************************************************************

    Public Function RadnomSelect(ByRef test_object)
       Dim intCount,stritem
        intCount=test_object.GetROProperty("items count")
        Randomize
        intCount=RandomNumber(0,intCount -1)
        test_object.Select intCount
        stritem=test_object.getitem(intCount+1)
        RadnomSelect=stritem
    End Function
    RegisterUserFunc "WebList", "RadnomSelect", "RadnomSelect"

    '************************************************************
    '@Description:为指定字符串加双引号
    '@Documentation:strbyquita需要加引号的字符串

    '************************************************************

    Public Function quotaString(ByRef strbyquita)

           Dim strInput

           If strbyquita<>"" Then

            strInput=chr(34)&strbyquita&chr(34)

           End If

        quotaString=strInput

       

    End Function

    '************************************************************

    '@Description选择wenlist并且输出该选项,不存在选项则退出测试

    '@test_object 测试对象(weblist)

    '@selectvaue 选择的项

    '************************************************************

    Public Function SelectAndOutput(ByRef test_object,ByRef selectvaue)

           on error resume next

           Dim arrOutput,flag,i

           Check = false: i = 0 

       arrOutput=test_object.GetROProperty("all items")

       arrOutput=split(arrOutput,";")

      Do While i < UBOUND(arrOutput)    

         I = I + 1 

         If arrOutput(i)=selectvaue Then 

            Check = true     

            Exit Do          

         End If

      Loop

    If   Check = true Then

                       test_object.select selectvaue

                     SelectAndOutput=selectvaue

                                else

                                reporter.reporterevent micfail, "weblist不存在此选项:"&selectvaue

                                exittest

    End If

           On error goto 0

    End Function

    RegisterUserFunc "WebList", "SelectAndOutput", "SelectAndOutput"

    '************************************************************

    '@Description比较数组是否相等
    '@Documentation<arr1><arr2>待比较的数组<arr1><arr2>
    '************************************************************
    Public Function compareArr(ByRef arr1, ByRef arr2)
      Dim strarr1,strarr2
      If (isarray(arr1)) and (isarray(arr2)) Then
     
      strarr1=join(arr1,"")
      strarr2=join(arr2,"")
      If strarr1<>strarr2 Then
       compareArr=false
       else
             compareArr=true
      End If
      else
      exit function
      End If
    End Function

  • 相关阅读:
    javascript命名规范
    angularjs指令参数transclude
    angular中的compile和link函数
    angularjs中的directive scope配置
    sublime text3同时编辑多行
    jquery中on/delegate的原理
    defered,promise回顾
    导航栏滚动到顶部后固定
    angularjs揭秘
    $stateParams
  • 原文地址:https://www.cnblogs.com/testware/p/2001752.html
Copyright © 2020-2023  润新知