共同探讨QTP相关问题
使用Object Repository Automation Objects and Methods操作对象库
上一篇 /
下一篇 2008-07-13 11:39:58
/ 个人分类:QTP
51Testing软件测试网/o-gy]!U{Dim RepositoryFrom,TOCollection51Testing软件测试网hW&|ZD-v
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
F0n;^e Kha0RepositoryFrom.Load "C:\Login.tsr"51Testing软件测试网 }at#@8ho)r/v
Set TOCollection = RepositoryFrom.GetAllObjectsByClass("WinButton")51Testing软件测试网
KOVNO*E
Msgbox TOCollection.Count51Testing软件测试网V"[
g*R{+x
b3zDVT
_8s051Testing软件测试网]@&yv5}9S0]具体可参照help文档中关于ObjectRepositoryUtil的应用.51Testing软件测试网 ba:S,n-W"`iS
51Testing软件测试网t@d7R
mIr8}'FK]0_0DimImageObj, PageObj, RepositoryFrom, RepositoryTo |
SetRepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil") |
SetRepositoryTo = CreateObject("Mercury.ObjectRepositoryUtil") |
RepositoryFrom.Load"C:\QuickTest\Tests\Flights.tsr" |
RepositoryTo.Load"E:\Temp\Tests\Default.tsr" |
0IzyBFn1Jb&s)Y[051Testing软件测试网9lu;\x%a
8N6P
W}pIs0FunctionEnumerateAllChildProperties(Root) |
DimTOCollection, TestObject, PropertiesCollection,Property, Msg |
SetTOCollection = RepositoryFrom.GetChildren(Root) |
Fori = 0ToTOCollection.Count - 1 |
SetTestObject = TOCollection.Item(i) |
Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine |
SetPropertiesCollection = TestObject.GetTOProperties() |
Forn = 0ToPropertiesCollection.Count - 1 |
SetProperty= PropertiesCollection.Item(n) |
Msg = Msg &Property.Name &"-"&Property.Value & vbNewLine |
EnumerateAllChildProperties TestObject |
)e"_5Y_zpbz*l0
!C'}]U)b0 51Testing软件测试网dYMC1QG6b2z^
FunctionEnumerateAllObjectsProperties(Root) |
DimTOCollection, TestObject, PropertiesCollection,Property, Msg |
SetTOCollection = RepositoryFrom.GetAllObjects(Root) |
Fori = 0ToTOCollection.Count - 1 |
SetTestObject = TOCollection.Item(i) |
Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine |
SetPropertiesCollection = TestObject.GetTOProperties() |
Forn = 0ToPropertiesCollection.Count - 1 |
SetProperty= PropertiesCollection.Item(n) |
Msg =Property.Name &"-"&Property.Value & vbNewLine |
51Testing软件测试网A9xL7hI&}2E;]a
)X6|qw5_4B0 51Testing软件测试网+wh;_0L_
FunctionRenameAllImages(Root) |
DimTOCollection, TestObject, PropertiesCollection,Property |
SetTOCollection = RepositoryTo.GetAllObjectsByClass("Image") |
Fori = 0ToTOCollection.Count - 1 |
SetTestObject = TOCollection.Item(i) |
RepositoryTo.RenameObject (TestObject,"Image "& i) |
RepositoryTo.UpdateObject TestObject |
51Testing软件测试网LM)}*rSD51Testing软件测试网A u R1as/}:K&@
{0O*]9rOb[
]Otg'A0FunctionRemoveAllLinks(Root) |
DimTOCollection, TestObject, PropertiesCollection,Property |
SetTOCollection = RepositoryFrom.GetChildren(Root) |
Fori = 0ToTOCollection.Count - 1 |
SetTestObject = TOCollection.Item(i) |
TOClass = TestObject.GetTOProperty("micclass") |
RepositoryFrom.RemoveObject Root, TestObject |
EnumerateAllChildProperties TestObject |
51Testing软件测试网"lSj+I6E1We51Testing软件测试网r!n[
h%Q
51Testing软件测试网v5L/a"w1yLAn
CallEnumerateAllChildProperties(Null) |
CallEnumerateAllObjectsProperties(Null) |
CallRenameAllImages(Null) |
SetImageObj = RepositoryFrom.GetObject("Browser(""CNN.com"").Page(""CNN.com"").Image(""Remains identified"")") |
If(NotIsNull(ImageObj))Then |
MsgBox RepositoryFrom.GetLogicalName(ImageObj) |
SetPageObj = RepositoryTo.GetObjectByParent("Browser(""CNN.com"")","Page(""CNN.com"")") |
If(NotIsNull(PageObj))Then |
MsgBox RepositoryTo.GetLogicalName(PageObj) |
RepositoryTo.AddObject ImageObj, PageObj |
收藏
举报
TAG:
QTP