Inserting data into text boxes from Excel or CSV file
Thanks for all the help so far.
I have managed to come to grips with recording steps in Test Compete and have recorded a few scripts that function really well, I have now hit a problem that may require some scripting work which I suck at [img]images/icons/smile.gif[/img]
Below is part of a script I recorded that completes a form that records new patient details, as you can see the text boxes are clearly labled so I now want to have this script run but populate the text feilds with info from a Excel or CSV file so I can create multiple clients. Can I do this via recording or do I need to edit the script to tell it what to do.
Re: Inserting data into text boxes from Excel or CSV file
To perform your task, you need to manually create a script that will read data from an Excel sheet or a CSV file. TestComplete has the special features to do this: the CSVDriver and ExcelDriver driver objects. You can use the CSVDriver driver to iterate through the lines of a file, obtain values stored in these lines and use these values in your data-driven tests. The ExcelDriver driver lets to iterate through the rows of an Excel sheet and obtain values stored in its cells. For example, the following sample script gets the contents of the "C:\Test.xls" file and sets these data to an edit field:
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">function GetDataFromExcel()
var MsExcel, wEditField, data;
MsExcel = DDT["ExcelDriver"]("C:\\Test.xls", "Sheet1"
wEditField = w1["WinFormsObject"]("firstNameTextBox"
while (! MsExcel["EOF"]() )
for(i = 0; i < MsExcel["ColumnCount"]; i++)
data = VarToStr(MsExcel["Value"](i));
}</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Please see the "Using DDT Drivers" help topic for details. Also, I recommend that you go through the "Using TestComplete | Scripting" section of the TestComplete on-line help. This section contains topics on writing scripts.