51Testing软件测试论坛
标题:
学习QuickTest.Application对象
[打印本页]
作者:
dreamsea123
时间:
2009-8-5 15:13
标题:
学习QuickTest.Application对象
简单学习了一下QuickTest.Application对象
小结一下:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim pDefColl 'As QuickTest.ParameterDefinitions ' Declare a Parameter Definitions collection
Dim pDef ' As QuickTest.ParameterDefinition ' Declare a ParameterDefinition object
Dim rtParams 'As QuickTest.Parameters ' Declare a Parameters collection
Dim rtParam ' As QuickTest.Parameter ' Declare a Parameter object
'Dim cnt, Indx As Integer
' 声明一个application对象
Set qtApp = CreateObject("QuickTest.Application")
'打开qtp
qtApp.Launch ' Start QuickTest
'qtp可显示
qtApp.Visible = True ' Make the QuickTest application visible
‘打开一个test
qtApp.Open "D:\QTP\Tests\testaction"
' 得到这个test中所有的参数的集合
Set pDefColl = qtApp.Test.ParameterDefinitions
'得到参数个数
cnt = pDefColl.Count
Indx = 1
' 显示每个参数的名称、类型、输出/输入参数、描述
While Indx <= cnt
Set pDef = pDefColl.Item(Indx)
MsgBox "Param name: " & pDef.Name & "; Type: " & pDef.Type & "; InOut: " & pDef.InOut & "; Description: " _
& pDef.Description & "Default value: " & pDef.DefaultValue
Indx = Indx + 1
Wend
’获取test的参数集合,可以进行赋值修改等操作
Set rtParams = pDefColl.GetParameters() ' Retrieve the Parameters collection defined for the test.
‘得到参数集合中的某个特定参数
Set rtParam = rtParams.Item("InParam1") ' Retrieve a specific parameter.
’给参数赋值
rtParam.Value = "Hello" ' Change the parameter value.
‘ 运行test,某个参数已经修改完毕
qtApp.Test.Run , True, rtParams ' Run the test with changed parameters.
MsgBox rtParams.Item("OutParam1").Value ' Display the value of an output parameter after the test runs.
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2