Forum Discussion

conehead's avatar
conehead
Occasional Contributor
8 years ago

Data Driven Loop based on a database table account numbers

I'm trying to figure out how to create a data driven loop in my keyword test based on database account numbers selected from within in a 'Run Script Routine'. Currently, I have a working 'Run Script Routine' pulling back a single account number without looping.  If I want to have a data driven loop execute based on the first five account number rows returned, what would be the simplest way to do this?

 

Thanks for your consideration.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not sure I entirely understand... 

     

    1) You have a script routine that returns a single account number.  Does that routine have parameters on it for determining which account number?  What exactly does that script routine do?

    2) What is inside the loop...the routine that returns the account number or are you using those account numbers to drive a loop that's going to execute something else?

     

    For me, the simplest way to do this is to have the script routine be parameterized to return a particular number of rows/accounts.  That would be returned as some sort of array or table that I could then use in a for-loop to loop through that fixed length array.  Each time through the loop, execute code with the contents of that record of the array.

     

    All doable in keyword tests, but I'd probably end up writing it in script code.

     

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

      If you are fetching the account numbers from sequential rows, you might consider rearranging your data.  If it takes 5 account numbers to do one pass of the test, then have 5 columns in the spreadsheet, with each row being the data for one pass. 

       

      This will let you use a simple keyword test DDT loop and will also make it easier to debug if the test stops in the middle.  You won't have to count through the whole sheet to figure out which set of 5 was in use at the time.

    • conehead's avatar
      conehead
      Occasional Contributor

      This is on a Oracle database. 

       

      The script routine has no parameters. It returns an account number. There is a rownum = 1 in the Where clause. (This was just a first stab but good enough for prove of concept.)

       

      The five account numbers will drive a loop that's going to execute something else.

       

      Tks.

  • conehead's avatar
    conehead
    Occasional Contributor

    The different type of loop mentioned (For loop) made me realize I shouldn't have been thinking Data Driven Loop. I went with a While loop and have had some success with that in my keyword test.

     

    Thanks!