标题: Simple Function design_Ask help [打印本页] 作者: db_qtp 时间: 2012-3-29 11:25 标题: Simple Function design_Ask help Need design one function as below scenario:
Click "Inquire" button- All fields should be non-editable (read-only)
Click "Edit" button- Some fields should be editable, some are non-editable
Click button(parameter) 'edit or inquire
select case parm
case 1 "inquiry"
--->verify all fields non_editable
case 2 "edit"
---->verify some fields are editable, some are non-editable作者: 正在更新 时间: 2012-3-29 13:38
For example:All Controls in the window are Existent,Theis "name","age","sex" editboxes are editable others are non-editable when click "edit" button
function checkeditable(ButtonId)
dim objChild,objDesc
dim editboxname(2)
editboxname(0)="name"
editboxname(1)="age"
editboxname(2)="sex"
set objDict=Description.create()
objDict."micclass"="Javaedit"
set objChild=javawindow("xxx").Childobjects(objDic)
select case cint(ButtonID)
case 1
javawindow("xxx").javabutton("Inquire").click
k=0
for i=0 to objChild.count-1
if objChild(i).checkproperty("editable",1,1) then
k=k+1
end if
next
if k=0 then
msgbox "all editboxes are non-editable "
else
msgbox "Error"
end if
case 2
javawindow("xxx").javabutton("edit").click
for i=0 to objChild.count-1
for k=0 to ubound(editboxname)
if objChild(i).getroproperty("editname")=editboxname(k) and objChild(i).checkproperty("editable",1,1) then
msgbox "the"&editboxname(k)&"is editable "
else if objChild(i).getroproperty("editname")=editboxname(k) and objChild(i).checkproperty ("editable",0,1) then
msgbox "the"&editboxname(k)&"is non-editable "
else if objChild(i).getroproperty("editname")<>editboxname(k) and objChild(i).checkproperty ("editable",0,1) then
msgbox "the "&objChild(i).getroproperty("editname")&"is non-editable "
else if objChild(i).getroproperty("editname")<>editboxname(k) and objChild(i).checkproperty ("editable",1,1) then
msgbox "the "&objChild(i).getroproperty("editname")&"is editable "
next
next
case else
msgbox "wrong prm"
end select
end function作者: db_qtp 时间: 2012-3-29 14:44 回复 2#正在更新
Appreciate your quick response. May I now what is the meaning for "objDict."micclass"="Javaedit""?作者: 正在更新 时间: 2012-3-29 15:58
SORRY ! The correct syntax is "objDict("micclass").value="Javaedit" because I wirite the code without doc , the wrong certain occured!作者: db_qtp 时间: 2012-3-29 17:45 本帖最后由 db_qtp 于 2012-3-29 17:53 编辑
I have updated code base on your version as below. It works fine. Thanks a ton again.
Browser("Name:=").Page("title:=").WebButton("Value:=Inquire").Click
dim objChild,objDesc
set objDesc=Description.create()
objDesc("micclass").value="Webedit"
If Browser("Name:=").Page("title:=").WebElement("").Exist(1) then
set objChild=Browser("Name:=").Page("title:=").Childobjects(ObjDesc)
For i=0 to objChild.count-1
If objChild(i).GetROProperty("html id")<>"" and objChild(i).GetROProperty("html id")<>"" and objChild(i).GetROProperty("html id")<>"" and objChild(i).GetROProperty("html id")<>""Then
if objChild(i).checkproperty("disabled",1,1) then
msgbox "This editboxe is non-editable "
else
msgbox "This edit box is editable in Inquire screen-Defect"
end if
End If
next作者: 正在更新 时间: 2012-3-29 18:40
“K” is a counter, if the "k" value is match the Expect value i think the Result is correct, else it's incorrect,It's not a must作者: db_qtp 时间: 2012-4-3 14:53 本帖最后由 db_qtp 于 2012-4-3 15:05 编辑