Showing results for 
Search instead for 
Did you mean: 

Clicking random buttons from popup form

Occasional Contributor

Clicking random buttons from popup form



I have been trying to make a 'random' function for mapped buttons in my test. so that every time the test loops, it will click one of the 12 buttons randomly.

how would I be able to do this? I am kind of new to TestComplete 🙂


I tried making a table but I wasn't able to link the WPFControlName to the button name in my table.



Community Hero

Re: Clicking random buttons from popup form

I know some folks like to do random testing like this... but I honestly question the benefit in an automated situation.  Computers like predictability.  So, you're telling it to randomly click something... then what?  How do you determine what happens next?  And, if you need to reproduce a bug found during the automation, how do you know what was actually done?

That said...


If you're using NameMapping, you could map each of the buttons with a name something like "button1, button2, button3, etc".  Then, use a randomizer math function for whatever code language you're using.  Take the result of that function and do something like this.

var buttonID = randomizeButtonID();
var myButton = Aliases.MyApp.MyForm.WaitAliasChild('button' + buttonID, 500);
if (myButton.Exists) myButton.Click();

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
New Here?
Join us and watch the welcome video:
Top Kudoed Authors