Forum Discussion

david_vardy's avatar
david_vardy
New Contributor
12 years ago

Creating a blind fuzz test: random mouse/keyboard entry.

Hi all,



Our software is a fullscreen application divided into different sections. Click in different areas reveals different recorded path names etc by TestComplete.



I'm interested to see if, as an aside from our normal testing, I can setup a simple script to blindly do the following anywhere around the interface - so not linked to names of screen components etc.



Actions to create a Fuzzy Blind Monkey test:



mouse entry

Random single clicks

Double clicks on same location (to confirm)

Random drags from A to B





keyboard entry

Enter button pressed at intervals

Escape button occasionally pressed

Random keyboard entry alphabet only

Random down and up arrows





Is there some code (I usually create scripts in jscript) that can achieve the basic random mouse click and keyboard entry to get me started? 



Many thanks!





















  • Hi David,

    You can use Sys.Desktop.Width, Math.floor(int) and  math.random()

    to simulate random clicks across the screen, something like 




     var xlocation = Math.floor(Math.random() * Sys.Desktop.Width);


     var ylocation = Math.floor(Math.random() * Sys.Desktop.Height);


     Sys.Desktop.MouseDown(1, xlocation, ylocation);


     Sys.Desktop.MouseUp(1, xlocation, ylocation);



    And to simulate a random key you can use windows VK Key Codes with the "Sys.Desktop.KeyDown(key)" method.

    for example to generate a key between A-Z you could use something like 

    var randkey = 30 + (Math.floor(Math.random() * 60))



    *Also don't forget to release the key using the .KeyUp method

  • Hi David,

    You can use Sys.Desktop.Width, Math.floor(int) and  math.random()

    to simulate random clicks across the screen, something like 




     var xlocation = Math.floor(Math.random() * Sys.Desktop.Width);


     var ylocation = Math.floor(Math.random() * Sys.Desktop.Height);


     Sys.Desktop.MouseDown(1, xlocation, ylocation);


     Sys.Desktop.MouseUp(1, xlocation, ylocation);



    And to simulate a random key you can use windows VK Key Codes with the "Sys.Desktop.KeyDown(key)" method.

    for example to generate a key between A-Z you could use something like 

    var randkey = 30 + (Math.floor(Math.random() * 60))



    *Also don't forget to release the key using the .KeyUp method

  • Thank you Yotim, most grateful for your reply. I look forward to trying this out.  Have a good week!
  • Just wanted to say, thanks again Yotim, this worked really well. Had a chance to put it together recently. Have a good week!