VBScript 常用函數(shù)總結(jié)
下面是我總結(jié)的VBScript中常用的函數(shù)及其用法。
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.
一般來(lái)說,所有的對(duì)象都可以使用此方法得到運(yùn)行時(shí)對(duì)象的實(shí)際值。
語(yǔ)法: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.
此方法可以解決由于等待系統(tǒng)進(jìn)行處理某些操作或網(wǎng)絡(luò)原因引起的測(cè)試對(duì)象同步問題。
語(yǔ)法: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.
可以得到一個(gè)字符串在另外一個(gè)字符串中首次出現(xiàn)的位置。
語(yǔ)法: InStr([start, ]string1, string2[, compare])
4,Split
Returns a zero-based, one-dimensional array containing a specified number of substrings.
此函數(shù)可以把原來(lái)用某個(gè)特殊字符串連接起來(lái)的字符串分割開,得到一個(gè)一維的數(shù)組。
5,UBound
Returns the largest available subscript for the indicated dimension of an array.
得到某個(gè)維度的最大值。
6,Trim
Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim)。
如果需要?jiǎng)h除字符串左邊的所有空格,那么可以使用LTrim 函數(shù);如果需要?jiǎng)h除字符串右邊的所有空格,那么可以使用RTrim 函數(shù)。如果需要?jiǎng)h除字符串左邊和右邊的所有空格,那么可以使用Trim 函數(shù)。
7,Ucase
Returns a string that has been converted to uppercase.
此函數(shù)可以把所有的字符都轉(zhuǎn)換成相應(yīng)的大寫。
8,LCase
Returns a string that has been converted to lowercase.
此函數(shù)可以把所有的字符都轉(zhuǎn)換成相應(yīng)的小寫。
9,Cstr
Returns an expression that has been converted to a Variant of subtype String.
由于VBScript只有一種類型Variant,你可以使用此函數(shù)把某個(gè)變量強(qiáng)制轉(zhuǎn)換成String類型。
10,CInt
Returns an expression that has been converted to a Variant of subtype Integer.
由于VBScript只有一種類型Variant,你可以使用此函數(shù)把某個(gè)變量強(qiáng)制轉(zhuǎn)換成Integer類型。
在描述性編程語(yǔ)句中,最常用的函數(shù)有:
11,Create
這是創(chuàng)建一類或一個(gè)對(duì)象時(shí)必須要使用的方法。
12,ChildObjects
使用此方法可以得到符合某些條件的一類對(duì)象的集合。
13,Count
使用使用此方法可以得到符合某些條件的一類對(duì)象的個(gè)數(shù)。
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的幫助里面找到。 個(gè)人的建議是:你最好按照 QTP里面提供的例子,自己使用這些函數(shù)自己寫幾行語(yǔ)句,運(yùn)行后看一下運(yùn)行結(jié)果,結(jié)合QTP幫助里面的說明,這樣學(xué)習(xí)會(huì)快,也記得牢固。
在輸出結(jié)果時(shí), 常用的函數(shù)有 Msgbox 和 Print 函數(shù)。Msgbox 函數(shù)在 QTP8.2 及其以上版本都可以使用;Print 函數(shù)需要在 QTP 9.2 版本上使用,QTP 8.2 不支持此函數(shù),不知道 QTP 9.0是否支持此函數(shù)。
希望大家共同總結(jié)一下,一起進(jìn)步。
上一篇:SQLids.vbs 0.7(最終版,以后改成gui界面的)
欄 目:vb
本文標(biāo)題:VBScript 常用函數(shù)總結(jié)
本文地址:http://mengdiqiu.com.cn/a1/vb/7525.html
您可能感興趣的文章
- 01-10VBScript教程 第十一課深入VBScript
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript語(yǔ)法速查及實(shí)例說明
- 01-10VBScript教程 第七課使用條件語(yǔ)句
- 01-10vbscript 可以按引用傳遞參數(shù)嗎?
- 01-10VBScript教程 第二課在HTML頁(yè)面中添加VBscript代碼
- 01-10VBScript教程 第十四課在VBScript中使用對(duì)象
- 01-10VBScript教程 第六課VBScript運(yùn)算符
- 01-10VBScript的入門學(xué)習(xí)資料
- 01-10MsgBox函數(shù)語(yǔ)言參考


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語(yǔ)法速查及實(shí)例說明
隨機(jī)閱讀
- 01-10delphi制作wav文件的方法
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 04-02jquery與jsp,用jquery
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子