51Testing软件测试论坛

标题: 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 编辑

回复 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
        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 编辑

回复 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)




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2