Forum Discussion

ghunter's avatar
ghunter
New Contributor
5 years ago

Updating variable(DB Table) using JScript

Sorry if this has been answered previouly but a search of the Community and Google didn't quite turn up what I need to move forward.

 

I have a KeywordTest that contains a Data-Driven Loop that is pointing at an Excel Worksheet.  It is working great but there is a desire to allow others to run the test vial TestExecute.  For this approach to work I'd initialize select variables with information obtained via an external file (Excel, CSV, or other).

 

The issue is being to update the variable (DB Table) that is associated with the Data-Driven Loop mentioned above using JScript.  Information I've located has allowed me to create a new Variable, read from a variable where the default value is currently defined; just not update/change the path to the Excel Datasource. 

FWIW: The "intelli-sense" allows me to see some of the methods and properties assocated with this variable but none that I've been able to change the source path/filename.  "initialDBTableVar" seemed promising but I wasn't able to see or even change the value that it contains.  

Thank you

 

 

 

6 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I would be tempted to have the other users make a copy of the Excel sheet they want to use and put in it a particular folder, then rename it to what the test expects to see.  Keeps you from having to mess with the test.

     

     

    • ghunter's avatar
      ghunter
      New Contributor

      Thank you for your response and coincidently I've considered it as an alternative approach.  In this instance, I'm using TestComplete as a utility to enter data into an application as opposed to actual application development/testing.   Loading of data will happen on a regular bases so I was looking for flexiblity for one running TestExcecute to update a "control file" prior to executing it.  Meaing, have them update a control file with the new file name, target instance of the application, and etc.

       

      I figured that since I can access the DB TABLE variable via JScript there's likely a means to update the Default Value as I would do manually within TestComplete.

       

      FWIW: If I can't update the variable dynamically then I'll likely do something similar to what you're proposing.

       

      Thanks again for responding.

       

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        You could do that with your control file but I would update everything before you run the DDT loop so you still don't need to update the part of the test that has all the references to the spreadsheet, etc.  Update variables with your control file and then run the loop.