Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Is there an alternative to the SilkTest mouse button Click() and DoubleClick() methods?

Is there an alternative to the SilkTest mouse button Click() and DoubleClick() methods?

Background

On occasion the SilkTest method DoubleClick() sometimes does not work. This usually happens when the application opens a dialog on the first click and carries out another function with the second click. The SilkTest doubleclick() method can be too fast.

Solution

The following function substitutes for the SilkTest Click() and DoubleClick() methods, allowing you to specify the window to work in, the mouse button (left, right, middle) and the click type (single, double). The function prototype needs to be placed below the tag in the parent window of the object to be worked on.

Function Prototype

NewClick(window wWindow,integer iButton,integer iClickType,integer iXpos,integer iYpos)

where

  • wWindow is the window name that contains the object to be clicked on
  • iButton is the button to be used: 1=left, 2=right, 3=middle
  • iClickType is the button action to be performed: 1=click, 2=doubleclick
  • iXpos and iYpos are the co-ordinates of the object to be actioned


iXpos and iYpos can be found by Recording Testcase and noting the co-ordinates of the non-functioning Click() or DoubleClick() command.

Code

The following must be placed at the head of the frame file:

[-] dll "user32.dll"

[ ] mouse_event (long dwFlags ,long dx,long dy,long cButtons,long dwExtraInfo)

[-] void NewClick(window wWindow, integer iButton,integer iClickType, integer x, integer  y)

[ ]

[ ] integer i=0

[ ]

[ ] // various Constants to manipulate different buttons on mouse

[ ] const MOUSEEVENTF_LEFTDOWN = 2

[ ] const MOUSEEVENTF_ABSOLUTE = 32768

[ ] const MOUSEEVENTF_LEFTUP = 4

[ ] const MOUSEEVENTF_MIDDLEDOWN = 14

[ ] const MOUSEEVENTF_MIDDLEUP = 64

[ ] const MOUSEEVENTF_MOVE = 1

[ ] const MOUSEEVENTF_RIGHTDOWN = 8

[ ] const MOUSEEVENTF_RIGHTUP = 16

[ ]

[ ] //Set the click type default

[-] if(iClickType!=2)

[ ] iClickType=1

[ ]

[ ] //Set the button default

[-] if(iButton>3 || iButton==0)

[ ] iButton=1

[ ]

[ ] // Move Mouse Pointer over current mouse object

[ ] //this.MoveMouse(x,y)

[ ] wWindow.MoveMouse(x,y)

[ ]

[ ] //Send message to mouse controller to press and release mouse at the specified position

[ ] //Left mouse button

[-] if(iButton==1)

[-] for(i=1;i<=iClickType;i++)

[ ] mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

[ ] mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

[ ]

[ ] //Right mouse button

[-] if(iButton==2)

[-] for(i=1;i<=iClickType;i++)

[ ] mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)

[ ] mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)

[ ]

[ ] //Middle mouse button

[-] if(iButton==3)

[-] for(i=1;i<=iClickType;i++)

[ ] mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)

[ ] mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)

[ ]

[ ] return

-

Insert the prototype under the parent window tag e.g.

-
[-] // window VBForm Navigator

[ ] // tag "Chart Navigator"

[ ]   // NewClick(window wWindow,int iButton,int iClickType,int x,int  y)

-
Call the method from the testcase as detailed in Function Prototype above e.g. doubleclick the left button
-

[ ]     // NewClick(Navigator.NavTree.ShipList.CurrentChart,1,2,136,77)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:15
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.