Forum Discussion

lshemla's avatar
lshemla
Occasional Contributor
11 years ago

Create Dynamic Parameter

Hi All

just joined to the forum :)

 I need some help to create a dynamic param in one step.

i followed this video and its work fine.

but i need to repeat step few times (not consistent)

so..is there a way to run my test (populate name field) so every time i will get uniqe name such as time stamp or counter?



5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    See attached for a similar example in a Keyword Test  :)

     

    The pt_part line in my test is an "On-Screen Action" from the menu using Code Expression "John " + Project.Variables.counter for the input.



    Let me know if you need more screenshots.  



  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Lior Lior



    You've not given us much to work with, but if I understand what you're after, something like this should help:





    function tester()

    {

      
    var txtCtrl = <your name field>;

      
    var name = "<some name>";



       f
    or (var i = 1; i <=10; i++)

      
    {

         
    name = name + i;

         
    txtCtrl.wText = name;

         
    // whatever test(s) you want to perform here

      
    }


    }





    This should append the value of the index counter of the for loop to name each time through the loop and place it in the name field, for example, if name is originally assigned "John", the each time through the loop, "John1", "John2", "John3", etc., will be used in the name field.  You can then perform whatever test(s) you require.  The above example will repeat 10 times, using the names "John1" through "John10" inclusive.



    Hope this helps!



    Regards

    Stephen.





    PS: I've just seen your second post after creating this one and wasn't aware that you were talking about keyword testing.  I'm afraid it's been a while since I used those, so not sure I can help you!! Sorry.


  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Lior,


     


    First of all, welcome to our community!


     


    You may want to generate random data with the specified format to put it in your test. You can use TestComplete's Data Generator wizard for this. Details...


    The wizard allows creating a project variable which you can call in your test like it's shown in Marsha's example.


     

  • lshemla's avatar
    lshemla
    Occasional Contributor
    Good morning :)

    thanks for all the answers :)


    i think that "Marsha Robertson"  solution is the one that im looking for.


    i did two variables: one for the constent name and one for the counter.


    but when i choose the step and want to implement those variables i can choose only one.


    the second issue...i cant get the counter to count up.


    thanks :)


    lior