其中脚本Browser("首页").Page("首页_2").Image("s").Click表示展现根菜单
录制脚本时为点击根菜单前面的+号,是个image对象
Browser("首页").Page("首页_2").Image("s_2").Click为打开下一级菜单
...
按群组授权是最下层菜单
脚本代码如何实现,能直接选中按群组授权这个link
因为它的上级菜单可以增加个,也可以减少个,一旦增加或减少后,那下次再回放这段脚本就出错了的,因为那些image对象,s,s_2,s_3就变化了的作者: zte_boy 时间: 2008-7-16 10:42
Function menuSelect(menuName)
Set curPage=Browser("creationtime:=0").Page("index:=0")
menu=split(menuName,"-")
curPage.WebElement("innerhtml:="&menu(0)).Click
For i= 1 to UBound(menu)
Set menuDesc = description.Create()
menuDesc("text").Value=menu(i)
menuDesc("micclass").Value = "Link"
if curPage.Exist(1) then
label = 0
While(label = 0)
Set menuLists = curPage.ChildObjects(menuDesc)
NumberOfLists = menuLists.Count()
If NumberOfLists=1 Then
menu(i)=menuLists.Item(0).GetROProperty("html id")
label = label + 1
elseif NumberOfLists>1 then
For j=0 to NumberOfLists
tempText=menuLists.Item(j).GetROProperty("html id")
If instr(tempText,menu(i-1))>0 Then
menu(i)=tempText
label = label + 1
Exit For
End If
Next
End If
Wend
curPage.Link("html id:="&menu(i)).Click
end if
Set menuLists = nothing
Set menuDesc = nothing
Next
Set curPage = nothing
End function
菜单格式为:一级—二级—三级 等
你只要把最下级的菜单路径输入进去就可以了作者: ylm77ojn 时间: 2008-7-16 15:22 标题: 回复 2# 的帖子 代码这样写的:
Dim menuName
menuName="按群组授权"
Set curPage=Browser("首页").Page("首页_2")
menu=split(menuName,"-")
curPage.WebElement("innerhtml:="&menu(0)).Click
For i= 1 to UBound(menu)
Set menuDesc = description.Create()
menuDesc("text").Value=menu(i)
menuDesc("micclass").Value = "Link"
if curPage.Exist(1) then
label = 0
While(label = 0)
Set menuLists = curPage.ChildObjects(menuDesc)
NumberOfLists = menuLists.Count()
If NumberOfLists=1 Then
menu(i)=menuLists.Item(0).GetROProperty("html id")
label = label + 1
elseif NumberOfLists>1 then
For j=0 to NumberOfLists
tempText=menuLists.Item(j).GetROProperty("html id")
If instr(tempText,menu(i-1))>0 Then
menu(i)=tempText
label = label + 1
Exit For
End If
Next
End If
Wend
curPage.Link("html id:="&menu(i)).Click
end if
Set menuLists = nothing
Set menuDesc = nothing
Next
Set curPage = nothing