NestedLoops.rst 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ***********
  2. NestedLoops
  3. ***********
  4. While working on TestCases we might need to repeat some TestSteps with a set of data and this data might be too dynamic
  5. or too much to use multiple fields (Quantity1, Quantity2, Quantity...).
  6. To provide a solution for this issue we have ``REPEAT`` & ``REPEAT-DONE`` activity tags, every activity between these
  7. two tags will be repeated as many times as there is data in the data source.
  8. And to counter big & complex data structure we have ``RLP_`` prefix which will take records written in another
  9. sheet, hence it will be much easier to enter and maintain data in separate sheet rather than within one single tab.
  10. RLP
  11. ===
  12. ``RLP_`` is a prefix which is used in the cell of a data sheet. Its structure is ``RLP_(sheetName, lineReference=Number)`` here
  13. sheetName will hold the name of sheet where main data is stored. LineRefernce holds the header name of the column which
  14. contains Reference Number in target sheet, with the help of this reference number a list of data matching the same reference
  15. number is made, which is then looped inside ``REPEAT`` activity. We can even use ``RLP_`` statement in a sheet previously
  16. targeted by an other ``RLP_`` prefix. Hence, we can create nested data and the data called by another ``RLP_`` data
  17. will become its child and the caller become its parent.
  18. .. image:: RLP_Nested_Loops.png
  19. .. image:: NestedLoopsSheet.png
  20. Here in image_1 inside ``RLP_`` LoopDataExampleTab is the sheetName of the target sheet containing main data and
  21. line_reference is the header which we are looking inside targetSheet, you can also see the header in image_2 which is of
  22. targetSheet. Then the value of header is matched.
  23. Like in first ``RLP_`` data value of line_reference is 0, which means
  24. it will create a list of data matching same in targetSheet, in this case their are 2 matching data so repeat statement
  25. will execute one after another.
  26. Repeat
  27. ======
  28. ``REPEAT`` tag is used in testrun file. It must be written inside "Activity" header and along with it, reference to the
  29. node referring to the data must be written inside ``Value`` tag. Format of node must be ``$(parent)`` (we have to replace
  30. parent with the header name where rlp data is stored).
  31. In *image_1* we can see "textarea2" is the header containing main
  32. data, so it will look like ``($textarea2)``. Now, if need to use child node we can use ``$(parent.child)`` here child is
  33. the name of header of the sheet which is replaced by ``RLP_`` prefix.
  34. In *image_2* we can see their is "input_text" header
  35. the sheet in image_2 replaces ``RLP_`` data of image_1 so it will look like ``$(textarea2.input_text)``. This node will
  36. be replaced by the value inside input_text and a loop will start on all the matching line_reference.
  37. And lastly we have a option to choose number of times loop is run. When we have a large number of data and we don't need
  38. to run loop on all we can input number in value2 tab, then the loop will be run on the same number of *randomly selected data*.
  39. If we want to run loop on all data we can simply leave the value2 tab empty or put 0.
  40. Also remember we need to use
  41. ``REPEAT-DONE`` at the end of the loop (i.e. from where we need to run again from the starting of the loop).
  42. Please see below image for further reference.
  43. .. image:: RepeatTag.png