Forum Discussion

dennis1's avatar
dennis1
Occasional Contributor
6 years ago

Clicking random buttons from popup form

Hi,

 

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.

 

Thanks!

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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();