Ask a Question

Nested datasourceloop

NehaLadani
Occasional Contributor

Nested datasourceloop

Hello Everyone

I have a POST Request to send and it has nested loop
{
       xyz:value
       abc:value [

      {

          pqr:value

          qaz:value

      }

]

}

Excelfile has 2 worksheets - Sheet A and Sheet B
1. Sheet A has values of xyz, abc
2. Sheet B has values of pqr, qaz - this section loops but sometimes 1, sometimes 2 and sometimes 3 depends on sheet A

3. Both files are linked with ID for our reference
Example Concept: IF
Sheet A - ID1 - has 1 row
Sheet B - ID1 - has 3 rows 

then the req sent will be
Request:

{
       xyz:value
       abc:value [

      {

          pqr:value1

          qaz:value1

      },

     {

          pqr:value2

          qaz:value2

      },

     {

          pqr:value3

          qaz:value3

      }

]

}

 

Response:
Has 1 output that is in the sheet A for comparision.

 

I got to know that we have to write groovy script, but have no idea how to write.
Can someone please write here in detail?
Or any other way to approach.

Thank you in advance.

4 REPLIES 4
SarahS
Staff

If you're using ReadyAPI Test you should be able to set this up fairly easy by using Data Source test steps and Data Source Loops. I've added in a screenshot that shows a sample structure on how this would be implemented. 


SarahS_0-1663879396083.png

 

NehaLadani
Occasional Contributor

Hello Saras, 
Thank you for your reply..

Can you please explain in words, how to do it.?
Thank you!

This is all done with the Data Source test step and the Data Source Loop test step. 
All that is required is adding one data source and loop for each set of data you want to use. 
Once the steps are added to your test case you can click and drag the steps to in the test case interface to place where the data is used. 

Setting up the data sources and loops are fairly simple. You can refer to the documentation here for help getting these set up. 
Data Source: https://support.smartbear.com/readyapi/docs/functional/steps/data-source.html
Data Source Loop: https://support.smartbear.com/readyapi/docs/functional/steps/data-source-loop.html

NehaLadani
Occasional Contributor

Thank you SarahS,

But, I know how to link datasource with readyAPI and to the rest request but the question is how to loop it for my requirement of having 2 worksheets in one excel file.
1 datasource  -  Same Excelfile  - sheet A properties

2 datasource - Same Excelfile - sheet B properties
1 rest request

Sometimes
{
Sheet A - id1

[

Sheet B (variable number of loops, id1- 1, 2, 3 row from sheet B)

]

}

Sometimes
{
sheet A - id2
[
Sheet B (variable number of loops, id2- 4, 5 row from sheet B)
]
}

Sometimes
{
sheet A - id3
[
Sheet B (variable number of loops, id3- 6, 7 row from sheet B)

]
}

Sometimes

{
sheet A - id4
[
Sheet B (variable number of loops, id4- 8, 9, 10 row from sheet B)

]
}

cancel
Showing results for 
Search instead for 
Did you mean: