利用Mercury.ObjectRepositoryUtil遍历对象库对象,出现,stopped working
创建vbs脚本如下:on error resumenext
Dim ImageObj, PageObj, RepositoryFrom, RepositoryTo
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
tsrPath="c:\查询.tsr"
RepositoryFrom.Load tsrPath
callEnumerateAllChildProperties(Root)
Set RepositoryFrom =nothing
msgbox "lixudong"
Function EnumerateAllChildProperties(Root)
Dim TOCollection, TestObject,Msg
Set TOCollection = RepositoryFrom.GetChildren(Root)
For i = 0 To TOCollection.Count - 1
Set TestObject = TOCollection.Item(i)
Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
msgboxMsg
SetTestObject=nothing
Next
Set TOCollection=nothing
End Function
执行这段代码后,界面出现stopped working异常,请问原因,这个代码我没有发现任何异常啊,请高手指点,谢谢!!!
C:\Users\lixudong\Desktop\12.png 我试了一下你的代码,把文件名改成英文就好了!没有出现你说的问题!
Dim ImageObj, PageObj, RepositoryFrom
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
tsrPath="c:\QTPTesting.tsr"
RepositoryFrom.Load tsrPath
下面是Help里面的东西,仅供参考:
'The following example retrieves an object repository's objects and properties,
'looks for specific test objects using several methods, and copies a test object
'to another object repository.
Dim ImageObj, PageObj, RepositoryFrom, RepositoryTo
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
Set RepositoryTo = CreateObject("Mercury.ObjectRepositoryUtil")
RepositoryFrom.Load "C:\QuickTest\Tests\Flights.tsr"
RepositoryTo.Load "E:\Temp\Tests\Default.tsr"
Function EnumerateAllChildProperties(Root)
'The following function recursively enumerates all the test objects directly under
'a specified parent object. For each test object, a message box opens containing the
'test object's name, properties, and property values.
Dim TOCollection, TestObject, PropertiesCollection, Property, Msg
Set TOCollection = RepositoryFrom.GetChildren(Root)
For i = 0 To TOCollection.Count - 1
Set TestObject = TOCollection.Item(i)
Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
Set PropertiesCollection = TestObject.GetTOProperties()
For n = 0 To PropertiesCollection.Count - 1
Set Property = PropertiesCollection.Item(n)
Msg = Msg & Property.Name & "-" & Property.Value & vbNewLine
Next
MsgBox Msg
EnumerateAllChildProperties TestObject
Next
End Function
Function EnumerateAllObjectsProperties(Root)
'The following function enumerates all the test objects under a specified object.
'For each test object, a message box opens containing the test object's name,
'properties, and property values.
Dim TOCollection, TestObject, PropertiesCollection, Property, Msg
Set TOCollection = RepositoryFrom.GetAllObjects(Root)
For i = 0 To TOCollection.Count - 1
Set TestObject = TOCollection.Item(i)
Msg = RepositoryFrom.GetLogicalName(TestObject) & vbNewLine
Set PropertiesCollection = TestObject.GetTOProperties()
For n = 0 To PropertiesCollection.Count - 1
Set Property = PropertiesCollection.Item(n)
Msg = Property.Name & "-" & Property.Value & vbNewLine
Next
MsgBox Msg
Next
End Function
页:
[1]