在描述性编程语句中,最常用的函数有:
11,Create
这是创建一类或一个对象时必须要使用的方法。
12,ChildObjects
使用此方法可以得到符合某些条件的一类对象的集合。
13,Count
使用使用此方法可以得到符合某些条件的一类对象的个数。
The following example uses the Create method to return a Properties collection object named EditDescription, and then uses the returned object to instruct QuickTest to enter the text: MyName in the first WebEdit object in the Mercury Tours page with the name UserName.
Set EditDesc = Description.Create()
EditDesc("micclass")。Value = "WebEdit"
EditDesc("Name")。Value = "userName"
Set Lists = Browser("Welcome: Mercury")。Page("Welcome: Mercury")。ChildObjects(EditDesc)
NumberOfLists = Lists.Count()
If NumberOfLists > 0 Then
Browser("Welcome: Mercury")。Page("Welcome: Mercury")。Lists(0)。Set "MyName"
End If
一些具体的用法可以在 QTP的帮助里面找到。 个人的建议是:你最好按照 QTP里面提供的例子,自己使用这些函数自己写几行语句,运行后看一下运行结果,结合QTP帮助里面的说明,这样学习会快,也记得牢固。
在输出结果时, 常用的函数有 Msgbox 和 Print 函数。Msgbox 函数在 QTP8.2 及其以上版本都可以使用;Print 函数需要在 QTP 9.2 版本上使用,QTP 8.2 不支持此函数,不知道 QTP 9.0是否支持此函数。
希望大家共同总结一下,一起进步。







