51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2615|回复: 4
打印 上一主题 下一主题

[原创] 脚本问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-6-27 23:45:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
'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:\Program Files\Mercury Interactive\QuickTest Professional\CodeSamplesPlus\Flight_Samples\SOR.tsr"

RepositoryTo.Load "C:\Program Files\Mercury Interactive\QuickTest Professional\dat\BPT_Resources\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

Function RenameAllImages(Root)
'The following function sets a new name for all image test objects under a specified object.
Dim TOCollection, TestObject, PropertiesCollection, Property
    Set TOCollection = RepositoryTo.GetAllObjectsByClass("Image")
    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            RepositoryTo.RenameObject (TestObject ("Image ") &  i )
            RepositoryTo.UpdateObject TestObject
    Next
End Function

Function RemoveAllLinks(Root)
'The following function recursively enumerates all the test objects under a specified object.
'It looks for all test objects of class Link and removes them from their parent objects.
    Dim TOCollection, TestObject, PropertiesCollection, Property
    Set TOCollection = RepositoryFrom.GetChildren(Root)
    For i = 0 To TOCollection.Count - 1
            Set TestObject = TOCollection.Item(i)
            TOClass = TestObject.GetTOProperty("micclass")
         If TOClass = "Link" Then
                RepositoryFrom.RemoveObject Root, TestObject
            End If
        EnumerateAllChildProperties TestObject
    Next
End Function

Call EnumerateAllChildProperties(Null)
Call EnumerateAllObjectsProperties(Null)
Call RenameAllImages(Null)
Call RemoveAllLinks(Null)
Set ImageObj = RepositoryFrom.GetObject("Browser(""CNN.com"").Page(""CNN.com"").Image(""Remains identified"")")
If (Not IsNull(ImageObj)) Then
MsgBox RepositoryFrom.GetLogicalName(ImageObj)
Else: MsgBox "null"
End If
Set PageObj = RepositoryTo.GetObjectByParent("Browser(""CNN.com"")", "Page(""CNN.com"")")
If (Not IsNull(PageObj)) Then
MsgBox RepositoryTo.GetLogicalName(PageObj)
Else: MsgBox "null"
End If
RepositoryTo.AddObject ImageObj, PageObj
RepositoryFrom.Save
RepositoryTo.Save


请问各位这个脚本是做什么用的,感觉好象是两个脚本进行比较,但不知道是不是,请各位大大给点提示,小第先谢谢了
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-6-28 01:21:50 | 只看该作者
原帖由 skyhen 于 2007-6-27 23:45 发表
'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. ...

注意看一下脚本最前面的注释,就是这段脚本的目的。

  1. 'The following example retrieves an object repository's objects and properties,
  2. 'looks for specific test objects using several methods, and copies a test object
  3. 'to another object repository.
  4. 下面的例子获取一个对象仓库的对象和属性,用几种方法查找特定的测试对象,并且把一个测试对象复制到另外一个对象仓库中。
复制代码
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-6-29 09:45:34 | 只看该作者
google来翻译一下
下面的例子返回一个对象库中的物品和财产,寻找特定的测试对象使用几种方法, 副本测试对象到另一个对象库.
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2007-7-16 14:01:34 | 只看该作者
看了几天还没看懂,
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2007-7-16 22:16:36 | 只看该作者
多谢共享,拷下来研究研究  sdlkfj2
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-16 20:45 , Processed in 0.072406 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表