Forum Discussion

Steve-3PO's avatar
Steve-3PO
New Contributor
7 years ago

Using an Excel DataSource with DataSourceLoop - Changing employee ID on each loop

 I am trying to load large amounts of data from an excel sheet using the DataSource tool, calling a REST API and then looping it with the DataSoureLoop until all rows in the excel sheet have sent via the PUT API call.

 

I have multiple employees that I want to create the same set of data for, and the only difference between each set of data is the EmployeeID. 

 

Example: I have 4 employees, and for each of them I want to create a 100 shifts. Instead of creating 400 rows in my excel (100 for each employee), and running the DataSourceLoop until it calls the API all 400 times, I want 100 rows in my Excel that I can loop as many times as there are employees.

 

Example:

Worksheet1: 

 |  Employee ID  |  Shift Start Date  |  Shift End Date

       0001             20-02-2018 1pm  20-02-2018 9pm

       0001             21-02-2018 1pm  21-02-2018 9pm

 

Worksheet1: 

|  Employee ID  |  Shift Start Date  |  Shift End Date

       0002             20-02-2018 1pm  20-02-2018 9pm

       0002             21-02-2018 1pm  21-02-2018 9pm

 

I hope this make sense. Any advice would be greatly appreciated.

 

Thanks,

 

  • Thank you for posting to our Community Forum. 

     

    You can nest DataSource loops so that for each employee you run through every possible shift. Here is how that could be structured. 

     

     

     

    1. Employee DataSource - contains all employee ids

    2. Shifts DataSource - contains all possible shifts

    3. API Call/ other needed TestSteps

    4. DataSource Loop to iterate the Shifts Data Source

    5. DataSource Loop to iterate the Employees DataSource. 

     

    Attached you can find the example TestCase XML File that I used to illustrate the structure. Note that I used a script to log the ids and shifts to show the concept since I don't have an API call to make. 

     

    Have a great day! 

  • StevenColon's avatar
    StevenColon
    SmartBear Alumni (Retired)

    Thank you for posting to our Community Forum. 

     

    You can nest DataSource loops so that for each employee you run through every possible shift. Here is how that could be structured. 

     

     

     

    1. Employee DataSource - contains all employee ids

    2. Shifts DataSource - contains all possible shifts

    3. API Call/ other needed TestSteps

    4. DataSource Loop to iterate the Shifts Data Source

    5. DataSource Loop to iterate the Employees DataSource. 

     

    Attached you can find the example TestCase XML File that I used to illustrate the structure. Note that I used a script to log the ids and shifts to show the concept since I don't have an API call to make. 

     

    Have a great day!