51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2375|回复: 8
打印 上一主题 下一主题

[原创] 用了ChildObjects方法,为什么报错呢?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2010-6-18 10:31:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Set decWebelement = Description.Create()
decWebelement("micclass").value= "WebElement"
set objWebelement = Browser("登录").Page("业务类型").ChildObjects(decWebelement)
a=objWebelement.count()
‘打印出来a=431’
msgbox a
For i = 0 to a-1
          ‘运行到下面这一步报错’
        Set abc = objWebelement(i).GetTOProperties
       .....
next



为什么呢?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2010-6-18 10:39:28 | 只看该作者
没看懂你想干嘛!
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2010-6-18 11:26:05 | 只看该作者
objWebelement.item(i).xxxxxx
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2010-6-18 15:10:26 | 只看该作者
看答案

[ 本帖最后由 vernzhang1980 于 2010-6-18 15:11 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2010-6-19 12:19:53 | 只看该作者
Set abc = objWebelement(i).GetTOProperties
改为
Set abc = objWebelement.item(i).GetTOProperties
回复 支持 反对

使用道具 举报

该用户从未签到

6#
 楼主| 发表于 2010-6-29 17:02:54 | 只看该作者
原帖由 k4124k 于 2010-6-19 12:19 发表
Set abc = objWebelement(i).GetTOProperties
改为
Set abc = objWebelement.item(i).GetTOProperties


还是不行,同样的报错信息
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2010-6-29 17:29:11 | 只看该作者

显示一个窗口的所有控件、子窗口及子窗口的控件、孙窗口

这是我刚学时写的一段代码,显示所有控件,比较方便的用于描述性编程,你看看是否有帮助:

testdebug1 是调用入口demo函数
'*printline 画表格的一行,notdata=true时画分隔行,notdata=false时画数据行
'strText是字符串,每隔用(%,)分开,如“abc%,def%,zzz”,必须大于16项数据
function printline(strText,notdata)
   Dim list ,i,strLine,width,nLen,cols
   cols=15
        width=split("12,10,8,12,8,6,6,6,14,15,18,18,6,6,20,20,10",",",-1,1)'每列宽度
   
   If notdata Then
                strLine="+"
        else
                strLine="|"
                list =split(strText,"%,",-1,1)
   End If
   For i=0 to cols
                If notdata Then
                        strLine=strLine&string(0+width(i),"-")
                else
                       
                        nLen=0+width(i)-len(list(i))
                        If nLen>0 Then
                                strLine=strLine&string(nLen," ")&list(i)
                        else
                                strLine=strLine&left(list(i),width(i)-3)&"..."
                        End If
                       
                       
                End If
           If   notdata Then
                   strLine=strLine&"+"
                else
                        strLine=strLine&"|"
           End If
          
   Next
        print strLine
        'printline =strLine&chr(10)
End function

Sub testdebug1
   Dim wndLogin
          
Set wndLogin=description.create()
wndLogin("regexpwndtitle").value="用户登录"
ListWindowProps wndLogin
End Sub

'ListWindowProps 函数用表格形式显示出一个窗口、对话框的所有控件的所有属性,如果有子窗口,也用递归方式显示另一个表格
'strDescript是一个对象,表示一个描述
Sub ListWindowProps(strDescript)
   Dim strLoginDlgTitle ,ctlAlias,listchild(10),listCount
   listCount=0
   Set oDesc = Description.Create()
        set children = window(strDescript).ChildObjects(oDesc)
        print ""
        print ""
    print ""
        printline "",true
        printline "Class Name%,window id%,visible%,nativeclass%,height%,width%,abs_x%,abs_y%,object class%,regexpwndclass%,windowextendedstyle%,windowstyle%,x%,y%,regexpwndtitle%,attached text",false
        printline "",True
        printline window(strDescript).GetROProperty("Class Name")& "%,"&window(strDescript).GetROProperty("window id")&"%,"&window(strDescript).GetROProperty("visible")&"%,"&window(strDescript).GetROProperty("nativeclass")&"%,"&window(strDescript).GetROProperty("height")&"%,"&window(strDescript).GetROProperty("width")&"%,"&window(strDescript).GetROProperty("abs_x")&"%,"&window(strDescript).GetROProperty("abs_y")&"%,"&window(strDescript).GetROProperty("object class")&"%,"&window(strDescript).GetROProperty("regexpwndclass")&"%,"&window(strDescript).GetROProperty("windowextendedstyle")&"%,"&window(strDescript).GetROProperty("windowstyle")&"%,"&window(strDescript).GetROProperty("x")&"%,"&window(strDescript).GetROProperty("y")&"%,"&window(strDescript).GetROProperty("regexpwndtitle")&"%,"&"主/子窗口",false
        printline "",true
         For i=0 to children.count-1
                 
                 printline children(i).GetROProperty("Class Name")& "%,"&children(i).GetROProperty("window id")&"%,"&children(i).GetROProperty("visible")&"%,"&children(i).GetROProperty("nativeclass")&"%,"&children(i).GetROProperty("height")&"%,"&children(i).GetROProperty("width")&"%,"&children(i).GetROProperty("abs_x")&"%,"&children(i).GetROProperty("abs_y")&"%,"&children(i).GetROProperty("object class")&"%,"&children(i).GetROProperty("regexpwndclass")&"%,"&children(i).GetROProperty("windowextendedstyle")&"%,"&children(i).GetROProperty("windowstyle")&"%,"&children(i).GetROProperty("x")&"%,"&children(i).GetROProperty("y")&"%,"&children(i).GetROProperty("regexpwndtitle")&"%,"&children(i).GetROProperty("attached text"),false
                printline "",true
                If  (children(i).GetROProperty("Class Name")="Dialog"  or  children(i).GetROProperty("Class Name")="Window" ) and children(i).GetROProperty("visible") then
            Set  listchild(listCount) = Description.Create()
                        listchild(listCount)("Class Name").value=children(i).GetROProperty("Class Name")
                        listchild(listCount)("window id").value=children(i).GetROProperty("window id")
                        listchild(listCount)("height").value=children(i).GetROProperty("height")
                        listchild(listCount)("width").value=children(i).GetROProperty("width")
                        listchild(listCount)("x").value=children(i).GetROProperty("x")
                        listchild(listCount)("y").value=children(i).GetROProperty("y")
       
                        listCount=listCount+1
                End If
         Next

        For i=0 to listCount-1
                        ListWindowProps listchild(i)
        Next
                  
End Sub
回复 支持 反对

使用道具 举报

该用户从未签到

8#
 楼主| 发表于 2010-6-30 09:44:52 | 只看该作者
谢谢,看起来很复杂的说,,,,
回复 支持 反对

使用道具 举报

该用户从未签到

9#
发表于 2010-6-30 16:00:55 | 只看该作者
你调试一下,看 i 是等于几的时候报错,又可能 i 等于某个值时取出来的WebElement不支持GetTOProperties方法,比如那个WebElement只是对应这样一个dom节点 "#text"
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-6-25 10:37 , Processed in 0.090216 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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