Forum Discussion

Zman_Tester's avatar
Zman_Tester
New Contributor
9 years ago

Data drive loop doesn't end at the end of the last row

Hi,

I am trying to create data-driven loop. 

I have an Excel spreadsheet where I store 'order numbers' and using TestComplete I am attempting to 'Complete' them. I have created the loop fine and it runs too but once it reaches the last 'Order number', it doesn't end the steps, goes back to the Order number 1 and attempts to rerun it. 

Could someone help me please? I have tried to recreate the steps over and over again and having no luck. Seems like I must be missing a setting somewhere.

 

Here is an screenshot of my test script: http://screencast.com/t/Qnxa9vgxD

 

Thanks in advance.

Zman.

  • dmiscannon's avatar
    dmiscannon
    9 years ago

    To set a breakpoint, click as shown below.

     

    When you run the script, TC will pause the test when it reaches the breakpoint. Then press F11 to advance the script one step at a time. The step being executed will be higlighted by TC. This may help you determine why the script is not performing as you want.

     

    Another possible solution would be to use an If..Then statement. In your Excel file, put a number, such as 9999, in the "Order Number" column in the row after the last row you wish to include in your test. Then, in the test, have an If..Then statement checking the value of "Order Number." If "Order Number" = 9999, use a Go To label to exit the DDT loop. Below is an example.

    The above is not ideal, but it may get the test to work while to you continue to debug the script.

  • dmiscannon's avatar
    dmiscannon
    Frequent Contributor

    Couple of things to try to find the issue:

    * Set the data loop to only read one record. Does it continually read the first record?

    * Set the data loop to only read two records. Does it restart at the beginning after reading the second record?

    * Set a breakstop on the first command inside of the data driven loop and then single step (F11) through the data loop. Watch what TestComplete is doing. This may help you find the issue.

    Good luck.

    • Zman_Tester's avatar
      Zman_Tester
      New Contributor

      Hi mate,

      Thank you for your reply. 

      My loop breaks regardless of record number. I tried with 1 record, and it tries to rerun the same record again and then the script fails. I want the loop to end soon as reaches to the last record.

      How do I do your point#3? Do you have an example please?

       

      Thank you

      Z

      • dmiscannon's avatar
        dmiscannon
        Frequent Contributor

        To set a breakpoint, click as shown below.

         

        When you run the script, TC will pause the test when it reaches the breakpoint. Then press F11 to advance the script one step at a time. The step being executed will be higlighted by TC. This may help you determine why the script is not performing as you want.

         

        Another possible solution would be to use an If..Then statement. In your Excel file, put a number, such as 9999, in the "Order Number" column in the row after the last row you wish to include in your test. Then, in the test, have an If..Then statement checking the value of "Order Number." If "Order Number" = 9999, use a Go To label to exit the DDT loop. Below is an example.

        The above is not ideal, but it may get the test to work while to you continue to debug the script.