Forum Discussion

KellyWiegand's avatar
KellyWiegand
Occasional Contributor
2 years ago

How to add a half-Auto-Increment variable?

Hi,

I want to add a variable which is like 'test10','test11','test12','test13'......it had a string part, and the number part can auto-increase. It's better if it can be a random number.

I know it can work by using the data-driven-loop, but how can I make it by variables and script?

Thank you!

  • For example,

    function main()
    {
        var name = "Test";
        var number = 0;
        
        for (var i = 0; i < 10; i++) {
            number = i; // increment
            Log.Message(name + number.toString());
        }
        
        Log.Message(Math.floor(Math.random() * 10)); // Returns a random integer from 0 to 9
    }
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    For example,

    function main()
    {
        var name = "Test";
        var number = 0;
        
        for (var i = 0; i < 10; i++) {
            number = i; // increment
            Log.Message(name + number.toString());
        }
        
        Log.Message(Math.floor(Math.random() * 10)); // Returns a random integer from 0 to 9
    }
    • KellyWiegand's avatar
      KellyWiegand
      Occasional Contributor

      Thank you, but how can I use these string in the keyword test?

      I want to do a search in loop, the search criteria for each time is one of these string.