February 10, 2008

Tip11 - To click on center position of a object

Sometimes script is required to click center of the objects. It depends upon the control classes. In few scenarios, silktest will return negative co-ordinates for particular objects. At that time, we can set the statement to click on center of the object. The code snippet is given below.

[+] public void ClickCenter(window wObjectName , boolean bIsRightClick optional)
[ ] // Clicking on Center point of any Object [Html Image , Text Etc.]
[ ]
[ ] RECT rWindowShape
[ ]
[ ] rWindowShape = wObjectName.GetRect (TRUE)
[ ]
[+] if ((bIsRightClick==NULL) || bIsRightClick==TRUE) // if Left click .?
[ ]
[ ] wObjectName.Click(2,rWindowShape.xSize/2,rWindowShape.ySize/2)
[ ]
[+] else
[ ]
[ ] wObjectName.Click(1,rWindowShape.xSize/2,rWindowShape.ySize/2)
[ ]

0 comments: