Forum Discussion

p_vd_berg's avatar
p_vd_berg
Occasional Contributor
14 years ago

data-driven-loop on different db-connections

We want to use TestComplete to execute a number of keyword tests every night.

It is one keywordtest that need to be executed with 8 different CSV files as input data.

So the problem is that the connection string for the DB-Table (CSV file) may vary.

How can i change the DB-table variable in a script so its runs the script for setten the DB-Table Variable and then use the data-driven loop?

In this post http://smartbear.com/forums/forum/post/?mode=singleThread&thread=6f00447d-3c60-475f-b7c8-aaa0f62bcca5 they suggest a workaround but unfortunately I get a 'Type mismatch" error.


Anyone know how I can get this to work?

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    As noted in that thread, there's no easy way to programatically change the source of the data driven loop via a keyword test.



    What I would suggest is to create a bit of script code to create a DDT object.  Something like:



    function CreateDDT(CSVFileName)

    {

    var LocalObject = DDT.CSVDriver(CSVFileName)

    }




    Then, in your keyword test, where you would normally use your Table data for input, use DDT.CurrentDriver.Value("ColumnName").  This would be wrapped in a while loop while DDT.CurrentDriver.EOF is not equal to true.  Within that while loop, you'd call DDT.CurrentDriver.Next.  After everthing is done looping, you can then call an Object Method to call DDT.CloseDriver and pass in as the parameter DDT.CurrentDriver.Name.



    Take a look at the screenshot attached to see a sketched out loop for this.
  • p_vd_berg's avatar
    p_vd_berg
    Occasional Contributor
    it was a little bit of a hassle, but eventually i've succeeded!

    Thanks for your help