db_qtp 发表于 2012-3-29 11:25:49

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:43

For example:All Controls in the windoware Existent,Theis "name","age","sex" editboxes areeditable others arenon-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"

setobjChild=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:58

回复 2# 正在更新


    Appreciate your quick response. May I now what is the meaning for "objDict."micclass"="Javaedit""?

正在更新 发表于 2012-3-29 15:58:22

SORRY ! The correct syntax is "objDict("micclass").value="Javaedit" because Iwirite the code withoutdoc ,the wrong certain occured!

db_qtp 发表于 2012-3-29 17:45:18

本帖最后由 db_qtp 于 2012-3-29 17:53 编辑

回复 4# 正在更新

Many thanks. But may I know why you use k here?

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
        setobjChild=Browser("Name:=").Page("title:=").Childobjects(ObjDesc)
                        For i=0 to objChild.count-1               
                                IfobjChild(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 isnon-editable "
                                                                else
                                                                  msgbox "This edit box is editable in Inquire screen-Defect"
                                                        end if
                                End If
                        next

正在更新 发表于 2012-3-29 18:40:01

“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:01

本帖最后由 db_qtp 于 2012-4-3 15:05 编辑

回复 6# 正在更新

Got it. Thanks.
Now need desgin another function as below scenario, do u have any ideas on that?

Step 1: Navigate to Grid Page. (This information can be extracted from below excel sheet)

SR#      Grid Page      Max Rows
1      Draft 1      8
2      Draft 2      3

Step 2: Identify Filter/Sort Fields(Columns) in the screen
Step 3: Store the data in the Column into local variable

Column 1      Column 2      Column3      …
Value 1      …      …      …
Value 2      …      …      …
Value 3      …      …      …
Value 4      …      …      …

Step 4: Filter all columns and validate
Step 5: Sort all columns (ASC/DSC)
页: [1]
查看完整版本: Simple Function design_Ask help