Forum Discussion

shahid24's avatar
shahid24
Contributor
8 years ago
Solved

Data Driven Test, in a new test run, would like to use last value used +1 .

Hi, I am playing a data driven web keyword test which takes input from an excel sheet. Before a new test run, would like to use last value used + 1, as a unique entry is required each time I run the test. I do not wan to each time update the excel sheet.

 

Please can you let me know how this is possible.


Thank you,

Shahid

  • I wouldn't do something like try to increment by 1.  Instead, add code to put some sort of unique identifier on the values.

     

    var driver = DDT.ExcelDriver('c:\data\myfile.xls', 'mysheet', true);
    var uniqueValue = aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%Y%m%d%H%M'); while (!driver.EOF){ Aliases.MyApp.MyForm.EditField.Keys(driver.Value('firstcolumn') + uniqueValue.); driver.Next(); }

     That way you can keep using the same spreadsheet over and over and always have unique data.  The above is just an example, obviously, depending upon the data and how you are using it, this might need adaptation.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I wouldn't do something like try to increment by 1.  Instead, add code to put some sort of unique identifier on the values.

     

    var driver = DDT.ExcelDriver('c:\data\myfile.xls', 'mysheet', true);
    var uniqueValue = aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%Y%m%d%H%M'); while (!driver.EOF){ Aliases.MyApp.MyForm.EditField.Keys(driver.Value('firstcolumn') + uniqueValue.); driver.Next(); }

     That way you can keep using the same spreadsheet over and over and always have unique data.  The above is just an example, obviously, depending upon the data and how you are using it, this might need adaptation.

    • Marsha_R's avatar
      Marsha_R
      Icon for Champion Level 3 rankChampion Level 3

      I agree with tristaanogre.  We started out with the +1 option and I not only clashed with my own data but the group ended up all clashing with each other, because we were all adding common items even though it was for different tests.  

       

      What we did was something like what tristaanogre suggested, but we created a project variable called idstring with that aqConvert fragment in it, and then anywhere in our tests where we needed a random number (or close anyway), then we just added

       

      eval(idstring)

       

      into the script.  That way we didn't have to declare it everywhere.