发布新日志

  • 两个并行的action间参数传递的方法

    2010-08-11 11:02:19

    QTP automation testing 项目测试中,脚本经常会有多个action,下面就介绍一下并行的action间参数传递的方法,同时作为自己的工作笔记记录一下。
    e.g.  有两个并行的action_test1,action_test2.action_test1有两个变量sql,sql_count(在我的实际测试项目中sql,sql_count是动态的,根据不同的条件得到的sql,sql_count也是不一

    样的。)
    sql="SELECT OFR_NM,OFR_ID,DL_SM,STS,MOD_ON,MOD_BY,LST_USE_DT,CRT_ON,CRT_BY from OFFER where (STS='DRFT' OR STS='CMPL') and (OFR_NM LIKE "&"'%"&str_offnm&"%'"+" OR OFR_NM LIKE "&"'%"&str_offnm1&"%'"+" OR OFR_NM LIKE "&"'%"&str_offnm2&"%')"+" ORDER BY OFR_ID ASC"
    sql_count="SELECT COUNT(*) from OFFER where (STS='DRFT' OR STS='CMPL') and (OFR_NM LIKE "&"'%"&str_offnm&"%'"+" OR OFR_NM LIKE "&"'%"&str_offnm1&"%'"+" OR OFR_NM LIKE "&"'%"&str_offnm2&"%')"


    现在想把action_test1的变量sql,sql_count传到action_test2中,有如下几步:
    1.action_test1中右键菜单-->Action-->Action Properties,Parameters tab页的Output parameters设置两个输出参数,type是string,如output_sql,output_sqlcount.
    2.action_test2中右键菜单-->Action-->Action Properties,Parameters tab页的Input parameters设置两个输入参数,type是string,如input_sql,input_sqlcount.
    3.切换到keyword View,选中action_test2,右键菜单-->Action Call Properties,Parameter Values tab页,将input_sql,input_sqlcount参数化,分别由action_test1的两个输出参数

    赋给其参数值。即input_sql对应output_sql,input_sqlcount对应output_sqlcount。
    4.在action_test1中,把变量赋值给参数:
    Parameter("output_sql")=sql
    Parameter("output_sqlcount")=sql_count
    5.在action_test2中,定义两个变量sql1,sql_count1,把参数值赋给变量:
    sql1=Parameter("input_sql")
    sql_count1=Parameter("input_sqlcount")

    这样经过传递,action_test2的两个变量sql1,sql_count1就有值了。参数传递成功。

  • 从字符串数组中随机取N个字符串,每次取不同字符串的实现方法

    2010-07-08 21:15:29

    最近QTP项目实际测试中,会遇到随机取值的问题。于是总结了一下。

    Dim arrayk,arr(7),k
    arrayk=array("k1","k2","k3","k4","k5","k6","k7","k8")
    rndnum=RandomNumber(1,8)
    msgbox rndnum

    For i=1 to rndnum
     x=RandomNumber(0,7)  
     If i=1 Then
         arr(0)=x
     else  
      For j=0 to i-2   
         If arr(j)=x Then
            x=RandomNumber(0,7)
            j=-1
         End If   
      Next
      arr(j)=x
     End If
     k=arrayk(x)
     msgbox k
    Next

  • 2007.07.04

    2007-07-04 14:42:53

    杭州,

    天气好热...

Open Toolbar