DDR爱好者之家 Design By 杰米
下面是我总结的VBScript中常用的函数及其用法。
1,GetROProperty
说明:You use the GetROProperty method to retrieve the current value of a test object property from a run-time object in your application.
一般来说,所有的对象都可以使用此方法得到运行时对象的实际值。
语法:object.GetROProperty (Property, [PropertyData])
如 ButtonName=Browser("QA Home Page")。Page("QA Home Page")。WebButton("Submit")。GetTOProperty("Name")
2,WaitProperty
说明:Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.
此方法可以解决由于等待系统进行处理某些操作或网络原因引起的测试对象同步问题。
语法:object.WaitProperty (PropertyName, PropertyValue, [TimeOut])
如
Window("Test")。Static("Status:")。WaitProperty "text", "Ready", 30000
3,Instr
Returns the position of the first occurrence of one string within another.
可以得到一个字符串在另外一个字符串中首次出现的位置。
语法: InStr([start, ]string1, string2[, compare])
4,Split
Returns a zero-based, one-dimensional array containing a specified number of substrings.
此函数可以把原来用某个特殊字符串连接起来的字符串分割开,得到一个一维的数组。
5,UBound
Returns the largest available subscript for the indicated dimension of an array.
得到某个维度的最大值。
6,Trim
Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim)。
如果需要删除字符串左边的所有空格,那么可以使用LTrim 函数;如果需要删除字符串右边的所有空格,那么可以使用RTrim 函数。如果需要删除字符串左边和右边的所有空格,那么可以使用Trim 函数。
7,Ucase
Returns a string that has been converted to uppercase.
此函数可以把所有的字符都转换成相应的大写。
8,LCase
Returns a string that has been converted to lowercase.
此函数可以把所有的字符都转换成相应的小写。
9,Cstr
Returns an expression that has been converted to a Variant of subtype String.
由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成String类型。
10,CInt
Returns an expression that has been converted to a Variant of subtype Integer.
由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成Integer类型。
在描述性编程语句中,最常用的函数有:
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是否支持此函数。
希望大家共同总结一下,一起进步。
1,GetROProperty
说明:You use the GetROProperty method to retrieve the current value of a test object property from a run-time object in your application.
一般来说,所有的对象都可以使用此方法得到运行时对象的实际值。
语法:object.GetROProperty (Property, [PropertyData])
如 ButtonName=Browser("QA Home Page")。Page("QA Home Page")。WebButton("Submit")。GetTOProperty("Name")
2,WaitProperty
说明:Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.
此方法可以解决由于等待系统进行处理某些操作或网络原因引起的测试对象同步问题。
语法:object.WaitProperty (PropertyName, PropertyValue, [TimeOut])
如
Window("Test")。Static("Status:")。WaitProperty "text", "Ready", 30000
3,Instr
Returns the position of the first occurrence of one string within another.
可以得到一个字符串在另外一个字符串中首次出现的位置。
语法: InStr([start, ]string1, string2[, compare])
4,Split
Returns a zero-based, one-dimensional array containing a specified number of substrings.
此函数可以把原来用某个特殊字符串连接起来的字符串分割开,得到一个一维的数组。
5,UBound
Returns the largest available subscript for the indicated dimension of an array.
得到某个维度的最大值。
6,Trim
Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim)。
如果需要删除字符串左边的所有空格,那么可以使用LTrim 函数;如果需要删除字符串右边的所有空格,那么可以使用RTrim 函数。如果需要删除字符串左边和右边的所有空格,那么可以使用Trim 函数。
7,Ucase
Returns a string that has been converted to uppercase.
此函数可以把所有的字符都转换成相应的大写。
8,LCase
Returns a string that has been converted to lowercase.
此函数可以把所有的字符都转换成相应的小写。
9,Cstr
Returns an expression that has been converted to a Variant of subtype String.
由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成String类型。
10,CInt
Returns an expression that has been converted to a Variant of subtype Integer.
由于VBScript只有一种类型Variant,你可以使用此函数把某个变量强制转换成Integer类型。
在描述性编程语句中,最常用的函数有:
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是否支持此函数。
希望大家共同总结一下,一起进步。
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年05月17日
2024年05月17日
- 刘欢.2004-经典20年珍藏锦集【新索】【WAV+CUE】
- 中唱唱片群星《好歌珍藏-游子情深》2CDWAV
- CD圣经上榜天碟1995-乌仁娜-《蒙古草原之歌》[WAV+CUE].
- 【电影原声】武满彻《旭日东升》1993[WAV+CUE整轨]
- Taylor Swift《THE TORTURED POETS DEPARTMENT》[320K/MP3][148.54MB]
- Taylor Swift《THE TORTURED POETS DEPARTMENT》[FLAC/分轨][405.72MB]
- Joyce Jonathan《法式松弛感 漫步香榭丽舍》[320K/MP3][80.8MB]
- 女神异闻录5佐仓双叶coop攻略 p5r佐仓双叶对话选项攻略
- 【民谣】张智《尼勒克小镇》[FLAC]
- 林一峰2018-TRAVELOGUE4ESCAPE[香港首版][WAV+CUE]
- MollyLewis《OnTheLips》(2024)[Hi-Res96kHz_24bitFLAC]
- Joyce Jonathan《法式松弛感 漫步香榭丽舍》[FLAC/分轨][230.77MB]
- 群星《影视剧 春色寄情人 原声带》[320K/MP3][394.18MB]
- 吴牧野《强者独白II 李斯特巅峰作品选》[320K/MP3][216.01MB]
- 女神异闻录5御船千早coop攻略 p5r御船千早对话选项攻略