Read from a .txt file through QTP

How to read from a flat file. you know what reading from flat files required to perform data driven testing mostly.
Excell is bit heavy to perform such operation and a .txt file can be treated as input to QTP.
Here is a sample code to read from a .txt file. by this procedure you can read character one by one.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\test.txt", 1)
Do Until objFile.AtEndOfStream
strCharacters = objFile.Readline
msgbox strCharacters

again one question might come to our mind how to get exactly the word or are looking by one character

here is the ans...

Dim fso,myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile= fso.opentextfile ("D:\test.txt",1)
While myfile.atendofline <> True
s=split (x, ";")

here we are splitting by ";".
Read from a .txt file through QTP Read from a .txt file through QTP Reviewed by Animesh Chatterjee on April 01, 2010 Rating: 5

No comments:

Powered by Blogger.