【软件自动化测试-QTP实战技能 23】== QTP 常用Functions
2011-09-02 10:24
555 查看
'Write Function to Count how many Browsers opend on desktop and close them all
Function Close_Browsers()
Dim oBrowser,Browsers,TotBrowsers,i
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"
Set Browsers = Desktop.ChildObjects(oBrowser)
TotBrowsers = Browsers.Count
Msgbox TotBrowsers
For i = 0 to TotBrowsers-1 Step 1
Browser(i).close
Next
End Function
—————————
ix) ‘Write Function to Count how many Buttons available in FR Window
Function Count_Buttons()
Dim oButton, Buttons, TotButtons, i
Set oButton=Description.Create
oButton(“Class Name”).Value=”WinButton”
Set Buttons=Window(“text:=Flight Reservation”).ChildObjects(oButton)
TotButtons=Buttons.Count
Msgbox TotButtons
End Function
Call Count_Buttons()
—————————–
x) ‘Write Function to Count how many Objects available in FR Window by specified Test Object class
Function Count_Objects(Object)
Dim obj, Objects, TotObjects, i
Set obj=Description.Create
obj(“Class Name”).Value=Object
Set Objects=Window(“text:=Flight Reservation”).ChildObjects(obj)
TotObjects=Objects.Count
Msgbox TotObjects
End Function
Call Count_Objects(“WinRadioButton”)
Call Count_Objects(“WinButton”)
Call Count_Objects(“WinEdit”)
Call Count_Objects(“WinComboBox”)
——————————–
xi) ‘Write function to capture all button names one by one from Login Dialog Box
Function Capture_Buttons()
Dim oButton, Buttons, TotButtons, i, myButton
Set oButton=Description.Create
oButton(“Class Name”).Value=”WinButton”
Set Buttons=Dialog(“text:=Login”).ChildObjects(oButton)
TotButtons=Buttons.Count
For i= 0 to TotButtons-1
myButton=Buttons(i).GetRoProperty(“text”)
Msgbox myButton
Next
End Function
Call Capture_Buttons()
'——————————————
xii) ‘Write function to Count Howmany Links available in Google Homepage
Function Count_Links()
Dim oLink, Links, TotLinks, i
Set oLink=Description.Create
oLink(“micclass”).Value=”Link”
Set Links=Browser(“title:=Google”).Page(“title:=Google”).ChildObjects(oLink)
TotLinks=Links.Count
Msgbox TotLinks
End Function
Call Count_Links()
'——————————————————————————-
Function Close_Browsers()
Dim oBrowser,Browsers,TotBrowsers,i
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"
Set Browsers = Desktop.ChildObjects(oBrowser)
TotBrowsers = Browsers.Count
Msgbox TotBrowsers
For i = 0 to TotBrowsers-1 Step 1
Browser(i).close
Next
End Function
—————————
ix) ‘Write Function to Count how many Buttons available in FR Window
Function Count_Buttons()
Dim oButton, Buttons, TotButtons, i
Set oButton=Description.Create
oButton(“Class Name”).Value=”WinButton”
Set Buttons=Window(“text:=Flight Reservation”).ChildObjects(oButton)
TotButtons=Buttons.Count
Msgbox TotButtons
End Function
Call Count_Buttons()
—————————–
x) ‘Write Function to Count how many Objects available in FR Window by specified Test Object class
Function Count_Objects(Object)
Dim obj, Objects, TotObjects, i
Set obj=Description.Create
obj(“Class Name”).Value=Object
Set Objects=Window(“text:=Flight Reservation”).ChildObjects(obj)
TotObjects=Objects.Count
Msgbox TotObjects
End Function
Call Count_Objects(“WinRadioButton”)
Call Count_Objects(“WinButton”)
Call Count_Objects(“WinEdit”)
Call Count_Objects(“WinComboBox”)
——————————–
xi) ‘Write function to capture all button names one by one from Login Dialog Box
Function Capture_Buttons()
Dim oButton, Buttons, TotButtons, i, myButton
Set oButton=Description.Create
oButton(“Class Name”).Value=”WinButton”
Set Buttons=Dialog(“text:=Login”).ChildObjects(oButton)
TotButtons=Buttons.Count
For i= 0 to TotButtons-1
myButton=Buttons(i).GetRoProperty(“text”)
Msgbox myButton
Next
End Function
Call Capture_Buttons()
'——————————————
xii) ‘Write function to Count Howmany Links available in Google Homepage
Function Count_Links()
Dim oLink, Links, TotLinks, i
Set oLink=Description.Create
oLink(“micclass”).Value=”Link”
Set Links=Browser(“title:=Google”).Page(“title:=Google”).ChildObjects(oLink)
TotLinks=Links.Count
Msgbox TotLinks
End Function
Call Count_Links()
'——————————————————————————-
相关文章推荐
- 【软件自动化测试-QTP实战技能 26】== QTP_Training:Environment Variables
- 【软件自动化测试-QTP实战技能 19】== 关闭 MESSAGE BOX 当关闭EXCEL 时
- 【软件自动化测试-QTP实战技能 21】== QTP_use RegExp 匹配numbers
- 【软件自动化测试-QTP实战技能 13】== QTP 判断 files Exists
- 【软件自动化测试-QTP实战技能 27】== QTP open ldif file
- 【软件自动化测试-QTP实战技能 3】== 数据库检查点手动SQL写法
- 【软件自动化测试-QTP实战技能 6】== QTP中运行错误的捕捉和记录
- 【软件自动化测试-QTP实战技能 28】== QTP_VbsTraining:Array Basics
- 【软件自动化测试-QTP实战技能 15】== QTP compare each iteration to enditeration
- 【软件自动化测试-QTP实战技能 7】== QTP中类的基本使用方法
- 【软件自动化测试-QTP实战技能 16】==QTP_调用外部EXCEL数据替换DataTable中的数据
- 【软件自动化测试-QTP实战技能 10】== QTP用到的一些特殊方法
- 【软件自动化测试-QTP实战技能 8】== QTP中页面的基本异常检查
- 【软件自动化测试-QTP实战技能 1】== 使用技巧实例
- 【软件自动化测试-QTP实战技能 28】== Minimize QTP
- 【软件自动化测试-QTP实战技能 5】== QTP中一些基础性代码结构
- 【软件自动化测试-QTP实战技能 11】== QTP code for excel link
- 【软件自动化测试-QTP实战技能 24】== QTP Code_ Useing Description Objects
- 【软件自动化测试-QTP实战技能 20】== QTP_ Delete files from Temp Folder:删除Folder
- 【软件自动化测试-QTP实战技能 4】== 取得Excel中的单元格值并作比较