webtable的2个很有用的函数-代码及用法
上一篇 / 下一篇 2010-12-04 12:23:02 / 个人分类:QTP/UFT
ObjectsByMicClass:返回WebTable中某一类型的所有对象集合51Testing软件测试网k,|ABN&R"a*l
ItemByKeyColumn:查找对象返回同一行中另一列的某类型的对象51Testing软件测试网\0|"^ l$]G/[]
‘-------------------------------------------------------------------------
qa$zPF(H,ae0' Function: ObjectsByMicClass51Testing软件测试网8a&~k"O)nWy:c
' Descrīption:返回webtable中某一类型的所有对象集合
pp$wdS0' Return Value:对象集合
Z @ n
E)Akq/FTQa0' Arguments:51Testing软件测试网&]Xm/lc
' Obj : 测试对象 (WebTable)
DoM*F;OWLV0' micClass :对象的micclass属性
‘---------------------------------------------------------------------------51Testing软件测试网hh2t4[g-R cb+Pzl
Function ObjectsByMicClass(Obj, micClass)
fZu-Ju)Ua3uS0Set Table = Obj
7oCe#I4n6Rg8?0' Create a collection object to hold the items
$W)@.Y1n9k0Set bjCollection = CreateObject("scripting.Dictionary")
&z\*X7_x0G0' Go over all the cells in the table, and look for objects with the specified micClass
&\G _Nzr&`!},a5q0For row=1 to Table.RowCount51Testing软件测试网z)S @|6`n \n
ColumnCount=Table.ColumnCount(row)51Testing软件测试网M{}.D.B2hd:l.G
For col=1 to ColumnCount51Testing软件测试网7|#EF9G*g ^e(Q0p
For ItemIndex=0 to Table.ChildItemCount(row, col, micClass)-151Testing软件测试网:p(d6Q2Kt
Set childItem=Nothing
i[+Aj0d{-d&[0Set childItem = Table.ChildItem(row, col, micClass, ItemIndex)
XW&S5_!RP0If Not childItem is Nothing Then
B5Ma8} WyS6|0' If the cell contains a micClass object, add it to the collection51Testing软件测试网l {,elf-Kg+DH
ItemKey = objCollection.Count + 1