cancel
Showing results for 
Search instead for 
Did you mean: 

Test complete dB table change in code depending on device

jewe
Occasional Contributor

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 5
tristaanogre
Community Hero

Re: Test complete dB table change in code depending on device

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
jewe
Occasional Contributor

Re: Test complete dB table change in code depending on device

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
Community Hero

Re: Test complete dB table change in code depending on device

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)

 

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
jewe
Occasional Contributor

Re: Test complete dB table change in code depending on device

I understand the idea, the only problem is that this object does not have the same interface as the DB Table.

Is there a property or a casting possible?

I could not find it in the TC documentation.

tristaanogre
Community Hero

Re: Test complete dB table change in code depending on device

No, there is not a casting available.  My suggestion is that you move away from using the DBTable variable type and move to the DDT object.

Again, that is depending a bit on what you are doing with the data.  The DDT object creates, essentially, a data record set that can be iterated through row by row, usually in a while loop.

If, however, you need something more direct, you can use the Excel.Application object to access the excel workbook.  The code is different but, again, you may need to rework how you are consumming the data object.

Basically...  there is no way to do what you are wanting to do using the DB Table variable type.  So, you need to convert to use a different method of connecting to your Excel database so you can have a more variable way of opening the files.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
New Here?
Join us and watch the welcome video:
Announcements