zoukankan      html  css  js  c++  java
  • 封装几个有用的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

  • 相关阅读:
    struts2 标签给iterator添加自然序号
    theirtts2
    zhihutheirTTS1
    theirs《A 2019 Guide to Speech Synthesis with Deep Learning》
    theirmvsnetv00000
    theirmvsnetv2
    theirMeshCNN/
    their MVF-Net: Multi-View 3D Face Morphable Model Regression(2019 CVPR)
    their DenseFusion6dof
    C++35
  • 原文地址:https://www.cnblogs.com/testware/p/2001752.html
Copyright © 2011-2022 走看看