Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
14 years ago

mouse vs cursor (focus?) current input position

Oh woe is the dreaded coordinates for clicking and right clicking. My dilemma is this. My application under test has a grid. The user has the ability to click on a row in the grid then right click there to bring up a pop up menu. I can get my cursor positioned on the correct row using the underlying properties of the grid. If send a right click with coordinates that match another row in the grid, I wind up with the wrong context for the context sensitive pop up menu. What I am doing is finding the lower right hand corner of the grid and right clicking there as there is generally no row there. This is not a highly desirable robust method.



I cannot use the MouseX or MouseY properties of the Desktop object because the mouse could be hovering anywhere on the screen unaffected by the grid's cursor/focus position change. (I am not even sure the correct term to use. I think cursor is right. If I am within a text box for instance, prepared to type, that is the position I would like to acquire. For example.)



Is this possible?


1 Reply

  • Hi Lane,


    What grid control are you using? If it is supported by TestComplete, you can try simulating clicks with the ClickCell and ClickCellR methods provided by the test engine for supported grid controls. Parameters of these methods let you specify the row and column for the click/right-click. This approach seems more reliable than using coordinates.


    Also, you wrote that you could select a row in the grid using the grid's internal methods and properties. I was wondering if there are methods or properties that let you obtain coordinates of this row. If the grid offers such methods (properties), you can use them to simulate mouse clicks.


    You can find more information on working with grid controls in TestComplete help:

    http://smartbear.com/support/viewarticle/13207/


    Also, you can search for code samples in the How To section of our web site:

    http://smartbear.com/support/howto/