Forum Discussion

jewe's avatar
jewe
Occasional Contributor
6 years ago

Test complete dB table change in code depending on device

Hello,

 

scrol down for the real question.

We have been using test compelete for years now and are very happy with it.

At the moment we are using an excel file as our database and the database is becoming too big.

It takes testcomplete more time to scan the database then to do the actual test.

This is oke from a test complete point of view as the database is 3 MiB big.

 

What I want to do is chop the database into several smaller databases.

Excel has the perference as we can use colours to help the test engineer.

 

The real question is:

How can I open an excel db table in VBscript? 

What I want is check for excel file for specific device, when found open that database, otherwise open the default.

This way I can do the segmentation in phases.

Thank you in advance,

 

jewest

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    How are you opening the file as a database now in TestComplete?  It seems a simple matter of some sort of if/then logic or case/switch statement.  Depending upon the result of the logic, assign the filename string to a variable which you then use in whatever code you have for opening the excel file.

    • jewe's avatar
      jewe
      Occasional Contributor

      Dear robert,

       

      Using the workspace --> temp var --> <var>

      which is a DB table with default value {Worksheet: "Sheet1"; workbook: "CommandDatabase.xls"}

       

      Best regards,

       

      Jewest

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        OK, so you're using a Project or ProjectSuite variable for your excel data.

        What you will probably need to do is replace that with script code.  I'm assuming you're doing a read-only view of the data table.  So, I would use the DDT.ExcelDriver method call to create an object to retrieve the data from the excel table.  

        In that method, you reference the name of the Excel file you want to use.  Replace that with a variable.  So, here's some pseudo-code.  Understand this is REALLY pseudo code and does not necessarily match a known syntax or structure, just presented to give the general idea. 

         

        var deviceName = CheckDevice() // <- some function or method to determine the device
        var excelFileName;
        
        case deviceName of
        
        'device1' : excelFileName = 'device1.xlsx'
        'device2' : excelFileName = 'device2.xlsx'
        else : excelFileName = 'default.xlsx'
        
        var databaseDriver = DDT.ExcelDriver('C:\\DataStore\\' + excelFileName, 'DATA', true)