Forum Discussion

ilim's avatar
ilim
New Contributor
13 years ago

Simulating mouse down/up events in a flex application

I'm trying to test a flex application which has the following  functionality: A user can click and hold down the mouse button on the display object and then drag the mouse around to perform a freehand sketch. When the user releases the mouse button the sketch is complete.



I understand that Test Complete does not directly support flex mouse down/up events but was hoping to be able to simulate it, possibly by manually dispatching the mouse down/up events ie. using the flex object's dispatchEvent() method. Is this possible or is there another way to this? If so, some JScript code would be extremely appreciated.



Ian
  • ilim's avatar
    ilim
    New Contributor
    Many thanks Alex - it was exactly what I needed. I basically converted the display object coordinates to screen coordinates by adding the display object ScreenLeft and ScreenTop offsets. This allows me to then use the LLPlayer mouse methods to mousedown, mousemove to a number of locations to simulate freehand movement and then mouseup to finish the sketch independent of the screen resolution and the position/size of the display object. Even managed to impress the other tester at my company with it - lol



    Cheers



    Ian
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Ian,


     


    I've voted for Alexei's reply on your behalf if you don't mind. In the future, you can do this on your own: Was this post helpful?  -> Yes.


    Voting for replies will be very important for the community members in the future :).


     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Thank you, Tanya :)



    Ian, to convert window/object coordinates to/from screen, you may consider ScreenToWindow() and WindowToScreen() methods of the tested object (see help for more details).

    I did not use these functions a lot, but hope that they will correctly do all the work that need to be done when converting coordinates in a multi-monitor system (with the second monitor positioned to the left of the first one and/or when the connected monitors have different resolutions).



    Tanya, could you please confirm whether ScreenToWindow()/WindowToScreen() work correctly in a multi-monitor environment? Just wondering...
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Alexei,


     




    Tanya, could you please confirm whether ScreenToWindow()/WindowToScreen() work correctly in a multi-monitor environment? Just wondering...




    Hmm... an interesting question... As far as I remember, the methods should use common coordinates for several monitors.