Forum Discussion

NehaLadani's avatar
NehaLadani
Occasional Contributor
2 years ago

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

  • 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.