Forum Discussion

Andrey_M's avatar
Andrey_M
Contributor
12 years ago

Data-driven loop: how to switch data source?

Hi guys.



I tried to find the answer but could not.



I have data-driven test based on data in Excel sheet but I need to switch the source (for another Excel workbook/sheet) depending on what user of my automated tests prefers.



I cannot use filters within a spreadsheet due to complexity of data (there are several workbooks depending on testing sites which can be selected by configuration (e.g. selecting site I change all locations of folders: input/output data, logging, archiving). Site is logical thing, all stuff runs on the same workstation.



I found two workarounds so far:

1) make a copy of workbook (whole Excel file) selected in configuration to some fixed location which addressed in DD variable;

2) make copy of a spreadsheet into table type variable and use this variable instead of Excel sheet. Unfortunately, this approach requires manual structure syncing of Excel sheet and table variable, otherwise I cannot assign fields (names) within a KDT.



I just hope that I missed something and more elegant solution exists.

4 Replies

  • Hi Andrey,

     


    Could you please answer the following questions to clarify your task?


    1. Do the Excel files in different sources contain the same structure of the content?


    2. Are you using DDT's methods to read data from Excel? 


     

  • Hi Tanya.



    Yes, the structure of Excel sources is identical regardless of location.



    I don't use DDT object,  I use Excel reference by DB table type variable from KDT. I see reference to data source (it looks like variable value) but it is not editable directly.

    I think that backdoor exists (modifiing reference to datasource directly in *.tcKDTest files but I don't like this approach: it may fail with next TC version release).



    I know how to use Excel for both way data exchange from scripts but I need switching of data sources in KDTs.
  • Thanks for the clarification, Andrey.

     


    At the moment, filling in a DBTable variable's source is possible only from the Project Editor. In our DB, we have a suggestion to add the possibility of accessing this parameter at the run time - I've added your vote to it.


     


    Did you try using DDT? Didn't it suit your needs?

  • Hi Tanya.



    Thank you for requesting this feature.



    No, I don't use DDT since I have my own Excel script extension library (OLE Excel control).



    Regards,

    Andrey