TestComplete Simple CSV Reader (C# script)

Automation is finally heating up at work and its tough to do any automation without reading your test definition files. I wrote mine in TestComplete’s C# scripting. This is a very simple script but why go re-write something if you have a solid base to start from? See the source or download the script file below.

function CSVReaderDriver(fileNameAndPath, lineToSplit){
fileContents = GetCSVContents(fileNameAndPath);
fileContentsByLine = SplitCSVContentsOnEnter(fileContents);
lineContents = SplitCSVLineOnComma(fileContentsByLine[lineToSplit]);

for (i = 0; i < lineContents["length"]; i++){
Log.Message(lineContents[i]);
}

return lineContents;
}

function GetCSVContents(filePathAndName){
return aqFile["ReadWholeTextFile"](filePathAndName, 22);
}

function SplitCSVContentsOnEnter(fileContents){
return fileContents["split"](Chr(13));
}

function SplitCSVLineOnComma(lineContents){
return lineContents["split"]("\, ");
}
 

TestDefinitionReader C# TestComplete Script

Facebook Twitter Linkedin

Related posts:

  1. Using a .NET assembly (DLL) with Test Complete 7.52
  2. SQL – QA Analyst Interview Problem
  3. Updated Summary Sheet in Excel (QA Test Scenario Template)
  4. File Parsing for Troubleshooting
  5. Summary Sheet in Excel using VBA Macro

About Mike

I am a Software Quality Assurance Professional that recently graduated college with a Bachelor's of Science in Computer Information Systems.
This entry was posted to the following categories: Automation, C#, Code Sample, Test Complete. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>