Forum Discussion

Wynand's avatar
Wynand
Occasional Contributor
14 years ago

Excel data

Hi All



Hope you can help me, I have data loops in my keyword test that reads data from excel spreadsheets. The problem is that it only reads the same

data from each excel sheet. There are 10 records in each sheet. Why wont it read the rest of the data if I re-run the test? Is there a way ?



I did specify "From beginning to End" & "From Record 1 to Record 10" but the result stays the same.



S/Sheet 1 = Account Numbers

S/Sheet2 = ID Numbers

7 Replies

  • Wynand,


    The problem is that it only reads the same data from each excel sheet.


    When you created a data loop, you specified the Excel sheet to be used as a data source. TestComplete reads data from this sheet in the range you specified. If you don't change the range, it reads the same data again and again (like any other robot :-) ).


    There are 10 records in each sheet. Why wont it read the rest of the data if I re-run the test?

    I did specify "From beginning to End" & "From Record 1 to Record 10" but the result stays the same.


    Sorry, but this is not clear to me. You said that the sheets have only 10 records. What other data do you expect TestComplete to read?


    Could you please clarify what you are trying to do and what data you are using?

  • Wynand's avatar
    Wynand
    Occasional Contributor
    Hi Alex



    I work for a bank in SOuth Africa



    I am testing account registrastions on our web portal. The data in the sheets are S/Sheet 1 = Account Numbers

    S/Sheet2 = ID Numbers (Simular to passport numbers). As you know the system does not allow you to do 2 registrastion numbers on the same account number or ID number.



    For a start I only entered 10 records in the S/Sheets for the test to see if I could get it working. I can add more data to the s/sheets if I want to. I only want TestComplete to use the data in my s/sheets in a incremental way.



    example. My test simulates a account registration and uses the first line in the s/sheets. This data is saved in the system, now i run the test again, but TestComplete does not read data form line 2 in the s/sheets?  I did not close TestComplete. Is it not suppose to use all the data from the sheet?  
  • Wyland,


    I guess, you are using the Data Loop operation in your keyword test. This operation works with one sheet only. It takes a record from the sheet, then execute operations in the loop body (they are displayed as child operations in the test editor), then takes the next record, executes operations in the loop body and so on. The operation continues these steps until it goes through all the records in the specified scope ("from 1 to 10", or "from beginning to end").


    It's difficult to understand what is going wrong without looking at your test. :-) As far as I understand you, you have one data loop in your keyword test and two Excel sheets.  Two situations are possible:


    * Your test takes only one value from Sheet 1 and only one value from Sheet 2.

    In this case, most likely, the operations which simulate user actions are not within the loop body (see the attached image).

    To fix the problem, include the operations to the loop body. To do this, select these operations in the test editor (you can use Ctrl- or Shift-click for multiselection) and click the green "right arrow" button on the editor's toolbar.

    After you moved the operations, please copy data from Sheet 2 to Sheet 1 in your Excel file and change your test, so that it works with one sheet only.


    * Your test goes through one sheet while another sheet "remains" at the same position.

    This happens because one data loop goes through one sheet only. It does not move the cursor in the other sheet, so the latter "remains" on the first record. To solve the problem, I'd suggest that you move data from your Sheet 2 to Sheet 1 (simple copy/paste columns in the Excel), so all the test data resides on the same sheet. After you do this, change your test commands so that they use the DB Table variable that provides connection to the appropriate sheet.


    Note that it's possible to use two sheets in the test, but this requires adding extra commands to your test (or writing script code). Moving data between sheets and modifying existing operations seems to be an easier solution.

  • Wynand's avatar
    Wynand
    Occasional Contributor
    Just to clear something up from my side.



    I use 3 excel spreadsheet files that are named differently and that have different data inside.My test does read data from all the files , but only the first lines from all files. All data in the files are on sheet 1 in the file. My files does have column headings.



    I do not have one data driven loop, I have a couple, some reading from one excel file but from different columns. But almost all of the data driven loop read from the same file to populate fields.



    My test starts by populating a field with a ID number( simulat to passport number). This data tipe only comes from 1 excel file (File 1). The system checks if account with this ID number exists.



    If not, it alows you to proceed with account registration. Here I use data loops to populate the bank card detail fields with the bank card data from one excel file (file 2).



    This completes succesfully. I then reissue the card (client lost his card). The system needs to search for client. Using the account number from file that was just used previously to do registration of account to search for client on system DB. System finds client and I the use data loop to populate Reissue bank card details from another excel file (File 3). This completes succesfully.



    When I run test again, TC uses the very same data just used in first run??? I noticed that it starts with the very last row in all 3 excel files. Each time??



    Now you know what happens in my keyword test (sort of) :)



    Im not sure if I should still follow your first advice? If so please confirm. I should have given this info earlier to give you  a better understanding. :)
  • When I run test again, TC uses the very same data just used in first run


    Yes. Each Data Loop operation works according to its properties. So, if the properties say "run from the 1st record to the 10th record", it will work within this scope every time. If you want the Data Loop operation to take the next record on every run, you need to modify the operation properties so that the operation takes the record you want. Alternatively, you can use additional test commands that will "skip" the records which you don't need. However, I wonder why you want to run tests only for one record each time? You can go through all the needed records in one test.


    Wyland, as far as I can see, the task you are talking about can be performed with TestComplete, but perhaps something is not configured properly in your test. I'd suggest that you send a sample test project and your data files to our Support Team, so that the guys can analyze your tests and see what is going wrong. Also, attach the link to this forum thread to your message.

  • Wynand's avatar
    Wynand
    Occasional Contributor
    Hi Alex, I do not see your attachment ?



    I would like to try your advice below and see if it works.



    * Your test takes only one value from Sheet 1 and only one value from Sheet 2.

    In this case, most likely, the operations which simulate user actions are not within the loop body (see the attached image).

    To fix the problem, include the operations to the loop body. To do this,
    select these operations in the test editor (you can use Ctrl- or
    Shift-click for multiselection) and click the green "right arrow" button
    on the editor's toolbar.

    After you moved the operations, please copy data from Sheet 2 to Sheet 1
    in your Excel file and change your test, so that it works with one
    sheet only.