标题: 用了ChildObjects方法,为什么报错呢? [打印本页] 作者: hollyecho 时间: 2010-6-18 10:31 标题: 用了ChildObjects方法,为什么报错呢? 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
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作者: hollyecho 时间: 2010-6-30 09:44
谢谢,看起来很复杂的说,,,,作者: Chain.Dai.China 时间: 2010-6-30 16:00
你调试一下,看 i 是等于几的时候报错,又可能 i 等于某个值时取出来的WebElement不支持GetTOProperties方法,比如那个WebElement只是对应这样一个dom节点 "#text"