Forum Discussion

armygrad's avatar
armygrad
Contributor
2 years ago

Data Driven tests from an excel file

Hi

 

I have created a excel file with a single column and 10 rows of data, how do i get the record from the excel file, to a specific part of

my POST call, called VRN.

 

Thanks

4 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

    The Smartbear site has some pretty good guides, but to be more specific for what you have...

     

    The below is the simplest of data-driven tests.  One datasource, the service to call and a loop.  This test will call the Rest request per row in the datasource.

     

    Here is my datasource.  Like yours, it's a single column.

    Note the properties section.  These align to our column(s) in the spreadsheet.  Also note I start at Row 2, this is because my spreadsheet contains a 'header row' and we don't want to pass a header to the service.

     

    The datasource loop has to be 'bound' to the datasource and you also have to bind it to the first step inside the loop.

    E.g.

    This seems counter-intuitive, but it does work.  The GUI also displays a nice arrow to show the loop.

     

    Your other question was "how to access the datasource value in a request".  To reference something in ReadyAPI, use the ${} syntax.  E.g. to reference the title for the current row in the datasource, use ${Books DataSource#title}.  The ${} styntax pulls in the value.  The bit before the hash is the step name of interest and the bit after the hash is the column.  So, if you added author as a another column in your spreadsheet, you'd add it to the properties section of the data source and reference it like ${Books DataSource#author}.

     

    You don't have to type this though, the best bit is the 'Get Data' menu option.  If you right-click in the payload section, you'll see Get Data.  Click it. This opens a modal window that allows you navigate around your test and pick the value you want to insert.

     

     

    The Get Data option is available everywhere in Ready API.  try right-clicking in fields or anywhere you'd expect to type.

     

     

     

     

    • armygrad's avatar
      armygrad
      Contributor

      Thanks

       

      My new issue is

       

      It works fine on the 1st run through, however on the 2nd run it goes from Delay 7 to Cancel, i need it to run as it did for the 1st run on all subsequent runs.

       

      Thanks